Program: 55391
Project: 55391
Buggy source:
/** 
 * Cancels and removes the task represented by this vertex from the instance it is currently running on. If the task is not currently running, its execution state is simply updated to <code>CANCELLED</code>.
 * @return the result of the task cancel attempt
 */
public TaskCancelResult cancelTask(){
  while (true) {
    final ExecutionState previousState=this.executionState.get();
    if (previousState == ExecutionState.CANCELED) {
      return new TaskCancelResult(getID(),AbstractTaskResult.ReturnCode.SUCCESS);
    }
    if (previousState == ExecutionState.FAILED) {
      return new TaskCancelResult(getID(),AbstractTaskResult.ReturnCode.SUCCESS);
    }
    if (previousState == ExecutionState.FINISHED) {
      return new TaskCancelResult(getID(),AbstractTaskResult.ReturnCode.SUCCESS);
    }
    if (previousState == ExecutionState.CANCELING) {
      return new TaskCancelResult(getID(),ReturnCode.SUCCESS);
    }
    if (previousState == ExecutionState.STARTING) {
      int retry=2000;
      while (this.executionState.get() == ExecutionState.STARTING) {
        if (--retry == 0) {
          return new TaskCancelResult(getID(),AbstractTaskResult.ReturnCode.ILLEGAL_STATE);
        }
        try {
          Thread.sleep(1);
        }
 catch (        InterruptedException ie) {
          return new TaskCancelResult(getID(),AbstractTaskResult.ReturnCode.ILLEGAL_STATE);
        }
      }
      continue;
    }
    if (compareAndUpdateExecutionState(previousState,ExecutionState.CANCELING)) {
      if (this.groupVertex.getStageNumber() != this.executionGraph.getIndexOfCurrentExecutionStage()) {
        updateExecutionState(ExecutionState.CANCELED,null);
        return new TaskCancelResult(getID(),AbstractTaskResult.ReturnCode.SUCCESS);
      }
      if (previousState != ExecutionState.RUNNING && previousState != ExecutionState.FINISHING && previousState != ExecutionState.REPLAYING) {
        updateExecutionState(ExecutionState.CANCELED,null);
        return new TaskCancelResult(getID(),AbstractTaskResult.ReturnCode.SUCCESS);
      }
      if (this.allocatedResource == null) {
        final TaskCancelResult result=new TaskCancelResult(getID(),AbstractTaskResult.ReturnCode.NO_INSTANCE);
        result.setDescription("String_Node_Str" + this.toString() + "String_Node_Str");
        return result;
      }
      try {
        return this.allocatedResource.getInstance().cancelTask(this.vertexID);
      }
 catch (      IOException e) {
        final TaskCancelResult result=new TaskCancelResult(getID(),AbstractTaskResult.ReturnCode.IPC_ERROR);
        result.setDescription(StringUtils.stringifyException(e));
        return result;
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Cancels and removes the task represented by this vertex from the instance it is currently running on. If the task is not currently running, its execution state is simply updated to <code>CANCELLED</code>.
 * @return the result of the task cancel attempt
 */
public TaskCancelResult cancelTask(){
  while (true) {
    final ExecutionState previousState=this.executionState.get();
    if (previousState == ExecutionState.CANCELED) {
      return new TaskCancelResult(getID(),AbstractTaskResult.ReturnCode.SUCCESS);
    }
    if (previousState == ExecutionState.FAILED) {
      return new TaskCancelResult(getID(),AbstractTaskResult.ReturnCode.SUCCESS);
    }
    if (previousState == ExecutionState.FINISHED) {
      return new TaskCancelResult(getID(),AbstractTaskResult.ReturnCode.SUCCESS);
    }
    if (previousState == ExecutionState.CANCELING) {
      return new TaskCancelResult(getID(),ReturnCode.SUCCESS);
    }
    if (previousState == ExecutionState.STARTING) {
      this.cancelRequested.set(true);
      if (this.executionState.get() != ExecutionState.STARTING) {
        this.cancelRequested.set(false);
        continue;
      }
      return new TaskCancelResult(getID(),AbstractTaskResult.ReturnCode.SUCCESS);
    }
    if (compareAndUpdateExecutionState(previousState,ExecutionState.CANCELING)) {
      if (this.groupVertex.getStageNumber() != this.executionGraph.getIndexOfCurrentExecutionStage()) {
        updateExecutionState(ExecutionState.CANCELED,null);
        return new TaskCancelResult(getID(),AbstractTaskResult.ReturnCode.SUCCESS);
      }
      if (previousState != ExecutionState.RUNNING && previousState != ExecutionState.FINISHING && previousState != ExecutionState.REPLAYING) {
        updateExecutionState(ExecutionState.CANCELED,null);
        return new TaskCancelResult(getID(),AbstractTaskResult.ReturnCode.SUCCESS);
      }
      if (this.allocatedResource == null) {
        final TaskCancelResult result=new TaskCancelResult(getID(),AbstractTaskResult.ReturnCode.NO_INSTANCE);
        result.setDescription("String_Node_Str" + this.toString() + "String_Node_Str");
        return result;
      }
      try {
        return this.allocatedResource.getInstance().cancelTask(this.vertexID);
      }
 catch (      IOException e) {
        final TaskCancelResult result=new TaskCancelResult(getID(),AbstractTaskResult.ReturnCode.IPC_ERROR);
        result.setDescription(StringUtils.stringifyException(e));
        return result;
      }
    }
  }
}