Program: 184242
Project: 184242
Buggy source:
public void onFinishTask() throws Exception {
  List<String> errors=new ArrayList<String>();
  for (  Entry<String,TaskField> field : getFields().entrySet()) {
    TaskField taskField=field.getValue();
    String error=taskField.validate();
    if (error != null)     errors.add(error);
    if (taskField.getActions() != null) {
      for (      Action action : taskField.getActions()) {
        if (action.getVariableType() != null) {
          if (action.getVariableType().equals(VariableType.PROCESS_VARIABLE)) {
            processManager.registerModifiedVariable(action.getVariable());
            processManager.updateVariableValue(action.getVariable(),taskField.getComponentValue());
          }
 else           if (action.getVariableType().equals(VariableType.ACTIVITY_VARIABLE)) {
            processManager.registerModifiedVariable(action.getVariable());
            updateVariableValue(action.getVariable(),taskField.getComponentValue());
          }
        }
 else         if (action.getType().equals(ActionType.SET_ATTACHMENT)) {
          ImmediateUpload upload=(ImmediateUpload)taskField.getComponent();
          try {
            processManager.getBpmModule().addAttachment(processManager.getProcessInstanceUUID(),taskField.getName(),upload.getFileName(),upload.getMimeType(),upload.getFileBody());
          }
 catch (          Exception e) {
            e.printStackTrace();
          }
        }
      }
    }
  }
  if (errors.size() > 0)   return;
  if (processManager.getTaskInstance() == null) {
    try {
      processManager.initializeNewProcess();
      processManager.finishTask(this);
    }
 catch (    ProcessNotFoundException e) {
      e.printStackTrace();
    }
catch (    VariableNotFoundException e) {
      e.printStackTrace();
    }
catch (    Exception e) {
      e.printStackTrace();
    }
  }
 else {
    processManager.finishTask(this);
  }
}

Fixed version (ground truth):
public void onFinishTask() throws Exception {
  List<String> errors=new ArrayList<String>();
  for (  Entry<String,TaskField> field : getFields().entrySet()) {
    TaskField taskField=field.getValue();
    String error=taskField.validate();
    if (error != null)     errors.add(error);
    if (taskField.getActions() != null) {
      for (      Action action : taskField.getActions()) {
        if (action.getVariableType() != null) {
          if (action.getVariableType().equals(VariableType.PROCESS_VARIABLE)) {
            processManager.registerModifiedVariable(action.getVariable());
            processManager.updateVariableValue(action.getVariable(),taskField.getComponentValue(action));
          }
 else           if (action.getVariableType().equals(VariableType.ACTIVITY_VARIABLE)) {
            processManager.registerModifiedVariable(action.getVariable());
            updateVariableValue(action.getVariable(),taskField.getComponentValue(action));
          }
        }
 else         if (action.getType().equals(ActionType.SET_ATTACHMENT)) {
          ImmediateUpload upload=(ImmediateUpload)taskField.getComponent();
          try {
            processManager.getBpmModule().addAttachment(processManager.getProcessInstanceUUID(),taskField.getName(),upload.getFileName(),upload.getMimeType(),upload.getFileBody());
          }
 catch (          Exception e) {
            e.printStackTrace();
          }
        }
      }
    }
  }
  if (errors.size() > 0)   return;
  if (processManager.getTaskInstance() == null) {
    try {
      processManager.initializeNewProcess();
      processManager.finishTask(this);
    }
 catch (    ProcessNotFoundException e) {
      e.printStackTrace();
    }
catch (    VariableNotFoundException e) {
      e.printStackTrace();
    }
catch (    Exception e) {
      e.printStackTrace();
    }
  }
 else {
    processManager.finishTask(this);
  }
}