### Question:
Task implements Runnable, TaskActions, PartitionProducerStateProvider, CheckpointListener { public StackTraceElement[] getStackTraceOfExecutingThread() { final AbstractInvokable invokable = this.invokable; if (invokable == null) { return new StackTraceElement[0]; } return invokable.getExecutingThread() .orElse(executingThread) .getStackTrace(); } Task(
		JobInformation jobInformation,
		TaskInformation taskInformation,
		ExecutionAttemptID executionAttemptID,
		AllocationID slotAllocationId,
		int subtaskIndex,
		int attemptNumber,
		Collection<ResultPartitionDeploymentDescriptor> resultPartitionDeploymentDescriptors,
		Collection<InputGateDeploymentDescriptor> inputGateDeploymentDescriptors,
		int targetSlotNumber,
		MemoryManager memManager,
		IOManager ioManager,
		ShuffleEnvironment<?, ?> shuffleEnvironment,
		KvStateService kvStateService,
		BroadcastVariableManager bcVarManager,
		TaskEventDispatcher taskEventDispatcher,
		TaskStateManager taskStateManager,
		TaskManagerActions taskManagerActions,
		InputSplitProvider inputSplitProvider,
		CheckpointResponder checkpointResponder,
		GlobalAggregateManager aggregateManager,
		BlobCacheService blobService,
		LibraryCacheManager libraryCache,
		FileCache fileCache,
		TaskManagerRuntimeInfo taskManagerConfig,
		@Nonnull TaskMetricGroup metricGroup,
		ResultPartitionConsumableNotifier resultPartitionConsumableNotifier,
		PartitionProducerStateChecker partitionProducerStateChecker,
		Executor executor); JobID getJobID(); JobVertexID getJobVertexId(); ExecutionAttemptID getExecutionId(); AllocationID getAllocationId(); TaskInfo getTaskInfo(); Configuration getJobConfiguration(); Configuration getTaskConfiguration(); AccumulatorRegistry getAccumulatorRegistry(); TaskMetricGroup getMetricGroup(); Thread getExecutingThread(); CompletableFuture<ExecutionState> getTerminationFuture(); StackTraceElement[] getStackTraceOfExecutingThread(); ExecutionState getExecutionState(); boolean isCanceledOrFailed(); Throwable getFailureCause(); void startTaskThread(); @Override void run(); @VisibleForTesting static void setupPartitionsAndGates(
		ResultPartitionWriter[] producedPartitions, InputGate[] inputGates); void cancelExecution(); @Override void failExternally(Throwable cause); @Override void requestPartitionProducerState(
			final IntermediateDataSetID intermediateDataSetId,
			final ResultPartitionID resultPartitionId,
			Consumer<? super ResponseHandle> responseConsumer); void triggerCheckpointBarrier(
			final long checkpointID,
			final long checkpointTimestamp,
			final CheckpointOptions checkpointOptions,
			final boolean advanceToEndOfEventTime); @Override void notifyCheckpointComplete(final long checkpointID); @Override String toString();  }### Answer:
@Test public void testReturnsEmptyStackTraceIfTaskNotStarted() throws Exception { final Task task = createTaskBuilder().build(); final StackTraceElement[] actualStackTrace = task.getStackTraceOfExecutingThread(); assertEquals(0, actualStackTrace.length); }