Program: 55398
Project: 55398
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(){
  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 (updateExecutionState(ExecutionState.CANCELING) != ExecutionState.CANCELING) {
    if (this.groupVertex.getStageNumber() != this.executionGraph.getIndexOfCurrentExecutionStage()) {
      updateExecutionState(ExecutionState.CANCELED,null);
      return new TaskCancelResult(getID(),AbstractTaskResult.ReturnCode.SUCCESS);
    }
    if (previousState == ExecutionState.FINISHED || previousState == ExecutionState.FAILED) {
      return new TaskCancelResult(getID(),AbstractTaskResult.ReturnCode.SUCCESS);
    }
    if (previousState != ExecutionState.RUNNING && previousState != ExecutionState.STARTING && 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;
    }
  }
  return new TaskCancelResult(getID(),ReturnCode.SUCCESS);
}

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(){
  ExecutionState previousState=this.executionState.get();
  int retry=1000;
  while (previousState == 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);
    }
    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 (updateExecutionState(ExecutionState.CANCELING) != ExecutionState.CANCELING) {
    if (this.groupVertex.getStageNumber() != this.executionGraph.getIndexOfCurrentExecutionStage()) {
      updateExecutionState(ExecutionState.CANCELED,null);
      return new TaskCancelResult(getID(),AbstractTaskResult.ReturnCode.SUCCESS);
    }
    if (previousState == ExecutionState.FINISHED || previousState == ExecutionState.FAILED) {
      return new TaskCancelResult(getID(),AbstractTaskResult.ReturnCode.SUCCESS);
    }
    if (previousState != ExecutionState.RUNNING && previousState != ExecutionState.STARTING && 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;
    }
  }
  return new TaskCancelResult(getID(),ReturnCode.SUCCESS);
}