Program: 95754
Project: 95754
Buggy source:
/** 
 * @param monitor the monitor to use
 * @param taskIdToALMChange the comment mapping
 * @return status
 */
private IStatus reportToALM(IProgressMonitor monitor,Map<String,List<ALMChange>> taskIdToALMChange){
  String repoLabel=m_reportProps.getALMRepositoryName();
  boolean failed=false;
  Set<String> taskIds=taskIdToALMChange.keySet();
  int taskAmount=taskIds.size();
  IProgressConsole c=getConsole();
  int successCount=0;
  if (taskAmount > 0) {
    String out=NLS.bind(Messages.ReportToALMJob,taskAmount,repoLabel);
    monitor.beginTask(out,taskAmount);
    c.writeLine(out);
    int overallCommentCount=0;
    int overallFieldUpdateCount=0;
    for (    String taskId : taskIds) {
      List<ALMChange> changes=taskIdToALMChange.get(taskId);
      List<CommentEntry> comments=new LinkedList<CommentEntry>();
      List<FieldUpdate> fieldUpdates=new LinkedList<FieldUpdate>();
      split(changes,comments,fieldUpdates);
      boolean commentingSucceeded=true;
      IStatus fieldUpdateStatus=Status.OK_STATUS;
      int commentAmount=comments.size();
      if (commentAmount > 0) {
        writeStatus(c,taskId,commentAmount,Messages.ReportingComment,Messages.ReportingComments);
        commentingSucceeded=ALMAccess.createComment(repoLabel,taskId,comments,monitor);
        if (!commentingSucceeded) {
          failed=true;
          c.writeErrorLine(NLS.bind(Messages.ReportingTaskFailed,taskId));
        }
 else {
          overallCommentCount+=commentAmount;
        }
      }
      int fieldUpdateAmount=fieldUpdates.size();
      if (fieldUpdateAmount > 0) {
        writeStatus(c,taskId,fieldUpdateAmount,Messages.ReportingFieldUpdate,Messages.ReportingFieldUpdates);
        fieldUpdateStatus=ALMAccess.updateFields(repoLabel,taskId,fieldUpdates,monitor);
        if (!fieldUpdateStatus.isOK()) {
          failed=true;
          c.writeErrorLine(fieldUpdateStatus.getMessage());
          c.writeErrorLine(NLS.bind(Messages.ReportingTaskFailed,taskId));
        }
 else {
          overallFieldUpdateCount+=fieldUpdateAmount;
        }
      }
      if (fieldUpdateStatus.isOK() && commentingSucceeded) {
        successCount++;
      }
      monitor.worked(1);
    }
    c.writeLine(NLS.bind(Messages.ReportToALMJobDone,new Integer[]{overallCommentCount,overallFieldUpdateCount,successCount,taskAmount}));
    monitor.done();
  }
 else {
    c.writeLine(Messages.NothingToReport);
  }
  if (!failed || successCount > 0) {
    return Status.OK_STATUS;
  }
  return new Status(IStatus.ERROR,Activator.ID,"String_Node_Str");
}

Fixed version (ground truth):
/** 
 * @param monitor the monitor to use
 * @param taskIdToALMChange the comment mapping
 * @return status
 */
private IStatus reportToALM(IProgressMonitor monitor,Map<String,List<ALMChange>> taskIdToALMChange){
  String repoLabel=m_reportProps.getALMRepositoryName();
  boolean failed=false;
  Set<String> taskIds=taskIdToALMChange.keySet();
  int taskAmount=taskIds.size();
  IProgressConsole c=getConsole();
  int successCount=0;
  if (taskAmount > 0) {
    String out=NLS.bind(Messages.ReportToALMJob,taskAmount,repoLabel);
    monitor.beginTask(out,taskAmount);
    c.writeLine(out);
    int overallCommentCount=0;
    int overallFieldUpdateCount=0;
    for (    String taskId : taskIds) {
      List<ALMChange> changes=taskIdToALMChange.get(taskId);
      List<CommentEntry> comments=new LinkedList<CommentEntry>();
      List<FieldUpdate> fieldUpdates=new LinkedList<FieldUpdate>();
      split(changes,comments,fieldUpdates);
      boolean commentingSucceeded=true;
      IStatus fieldUpdateStatus=Status.OK_STATUS;
      int commentAmount=comments.size();
      if (commentAmount > 0) {
        writeStatus(c,taskId,commentAmount,Messages.ReportingComment,Messages.ReportingComments);
        commentingSucceeded=ALMAccess.createComment(repoLabel,taskId,comments,monitor);
        if (!commentingSucceeded) {
          failed=true;
          c.writeErrorLine(NLS.bind(Messages.ReportingTaskFailed,taskId));
        }
 else {
          overallCommentCount+=commentAmount;
        }
      }
      int fieldUpdateAmount=fieldUpdates.size();
      if (fieldUpdateAmount > 0) {
        writeStatus(c,taskId,fieldUpdateAmount,Messages.ReportingFieldUpdate,Messages.ReportingFieldUpdates);
        fieldUpdateStatus=ALMAccess.updateFields(repoLabel,taskId,fieldUpdates,monitor);
        if (!fieldUpdateStatus.isOK()) {
          failed=true;
          c.writeErrorLine(fieldUpdateStatus.getMessage());
          c.writeErrorLine(NLS.bind(Messages.ReportingTaskFailed,taskId));
          if (fieldUpdateStatus.getSeverity() == IStatus.CANCEL) {
            break;
          }
        }
 else {
          overallFieldUpdateCount+=fieldUpdateAmount;
        }
      }
      if (fieldUpdateStatus.isOK() && commentingSucceeded) {
        successCount++;
      }
      monitor.worked(1);
    }
    c.writeLine(NLS.bind(Messages.ReportToALMJobDone,new Integer[]{overallCommentCount,overallFieldUpdateCount,successCount,taskAmount}));
    monitor.done();
  }
 else {
    c.writeLine(Messages.NothingToReport);
  }
  if (!failed || successCount > 0) {
    return Status.OK_STATUS;
  }
  return new Status(IStatus.ERROR,Activator.ID,"String_Node_Str");
}