### Question:
TaskImpl implements Task, EventHandler<TaskEvent> { @Override public boolean canCommit(TaskAttemptId taskAttemptID) { readLock.lock(); boolean canCommit = false; try { if (commitAttempt != null) { canCommit = taskAttemptID.equals(commitAttempt); LOG.info("Result of canCommit for " + taskAttemptID + ":" + canCommit); } } finally { readLock.unlock(); } return canCommit; } TaskImpl(JobId jobId, TaskType taskType, int partition,
      EventHandler eventHandler, Path remoteJobConfFile, JobConf conf,
      TaskAttemptListener taskAttemptListener,
      Token<JobTokenIdentifier> jobToken,
      Credentials credentials, Clock clock,
      int appAttemptId, MRAppMetrics metrics, AppContext appContext); @Override TaskState getState(); @Override Map<TaskAttemptId, TaskAttempt> getAttempts(); @Override TaskAttempt getAttempt(TaskAttemptId attemptID); @Override TaskId getID(); @Override boolean isFinished(); @Override TaskReport getReport(); @Override Counters getCounters(); @Override float getProgress(); @VisibleForTesting TaskStateInternal getInternalState(); @Override boolean canCommit(TaskAttemptId taskAttemptID); @Override void handle(TaskEvent event);  }### Answer:
@Test public void testKillDuringTaskAttemptCommit() { mockTask = createMockTask(TaskType.REDUCE); TaskId taskId = getNewTaskID(); scheduleTaskAttempt(taskId); launchTaskAttempt(getLastAttempt().getAttemptId()); updateLastAttemptState(TaskAttemptState.COMMIT_PENDING); commitTaskAttempt(getLastAttempt().getAttemptId()); TaskAttemptId commitAttempt = getLastAttempt().getAttemptId(); updateLastAttemptState(TaskAttemptState.KILLED); killRunningTaskAttempt(commitAttempt); assertFalse(mockTask.canCommit(commitAttempt)); }