Program: 96983
Project: 96983
Buggy source:
private DispoItemData buildNewItem(DispoItemData destItem,DispoItem sourceItem,boolean isCoverageCopy,OperationReport report,boolean isSameDiscrepancies) throws JSONException {
  boolean isChangesMade=false;
  DispoItemData newItem=initNewItem(destItem,sourceItem);
  JSONArray newAnnotations=newItem.getAnnotationsList();
  JSONArray sourceAnnotations=sourceItem.getAnnotationsList();
  Set<String> destDefaultAnntationLocations=getDefaultAnnotations(newItem);
  for (int i=0; i < sourceAnnotations.length(); i++) {
    JSONObject annotationJson=sourceAnnotations.getJSONObject(i);
    DispoAnnotationData sourceAnnotation=DispoUtil.jsonObjToDispoAnnotationData(annotationJson);
    String sourceLocation=sourceAnnotation.getLocationRefs();
    if (DispoUtil.isDefaultAnntoation(sourceAnnotation)) {
      if (!destDefaultAnntationLocations.contains(sourceLocation)) {
        report.addMessageForItem(destItem.getName(),"String_Node_Str",sourceAnnotation.getLocationRefs());
      }
    }
 else     if (isCoverageCopy && destDefaultAnntationLocations.contains(sourceLocation)) {
      report.addMessageForItem(destItem.getName(),"String_Node_Str",sourceAnnotation.getLocationRefs());
    }
 else     if (newAnnotations.toString().contains(sourceAnnotation.getGuid())) {
      report.addMessageForItem(destItem.getName(),"String_Node_Str",sourceAnnotation.getLocationRefs(),sourceAnnotation.getGuid());
    }
 else {
      if (isSameDiscrepancies || isCoverageCopy && isCoveredDiscrepanciesExistInDest(destItem,sourceItem,sourceAnnotation,report)) {
        DispoAnnotationData newAnnotation=sourceAnnotation;
        if (destDefaultAnntationLocations.contains(sourceLocation)) {
          String locationRefs=sourceAnnotation.getLocationRefs();
          Integer locationRefAsInt=Integer.valueOf(locationRefs);
          if (locationRefAsInt > 0) {
            newAnnotation.setLocationRefs(String.valueOf(locationRefAsInt * -1));
          }
          report.addMessageForItem(destItem.getName(),"String_Node_Str",locationRefs);
        }
        connector.connectAnnotation(newAnnotation,newItem.getDiscrepanciesList());
        isChangesMade=true;
        int nextIndex=newAnnotations.length();
        newAnnotation.setIndex(nextIndex);
        newAnnotations.put(nextIndex,DispoUtil.annotationToJsonObj(newAnnotation));
      }
    }
  }
  if (isChangesMade) {
    newItem.setAnnotationsList(newAnnotations);
    String newStatus=connector.getItemStatus(newItem);
    newItem.setStatus(newStatus);
  }
 else   if (isCoverageCopy) {
    newItem=destItem;
    newItem.setGuid(sourceItem.getGuid());
  }
 else {
    report.addMessageForItem(destItem.getName(),"String_Node_Str");
    newItem=null;
  }
  return newItem;
}

Fixed version (ground truth):
private DispoItemData buildNewItem(DispoItemData destItem,DispoItem sourceItem,boolean isCoverageCopy,OperationReport report,boolean isSameDiscrepancies) throws JSONException {
  boolean isChangesMade=false;
  DispoItemData newItem=initNewItem(destItem,sourceItem);
  JSONArray newAnnotations=newItem.getAnnotationsList();
  JSONArray sourceAnnotations=sourceItem.getAnnotationsList();
  Set<String> destDefaultAnntationLocations=getDefaultAnnotations(newItem);
  Map<String,Integer> placeHolderAnnotationLocations=getPlaceHolderAnnotations(newItem);
  for (int i=0; i < sourceAnnotations.length(); i++) {
    JSONObject annotationJson=sourceAnnotations.getJSONObject(i);
    DispoAnnotationData sourceAnnotation=DispoUtil.jsonObjToDispoAnnotationData(annotationJson);
    String sourceLocation=sourceAnnotation.getLocationRefs();
    if (DispoUtil.isDefaultAnntoation(sourceAnnotation) || !Strings.isValid(sourceAnnotation.getResolutionType())) {
      if (!destDefaultAnntationLocations.contains(sourceLocation)) {
        report.addMessageForItem(destItem.getName(),"String_Node_Str",sourceAnnotation.getLocationRefs());
      }
    }
 else     if (destDefaultAnntationLocations.contains(sourceLocation)) {
      report.addMessageForItem(destItem.getName(),"String_Node_Str",sourceAnnotation.getLocationRefs());
    }
 else     if (newAnnotations.toString().contains(sourceAnnotation.getGuid())) {
      report.addMessageForItem(destItem.getName(),"String_Node_Str",sourceAnnotation.getLocationRefs(),sourceAnnotation.getGuid());
    }
 else {
      if (isSameDiscrepancies && isCoveredDiscrepanciesExistInDest(destItem,sourceItem,sourceAnnotation,report)) {
        DispoAnnotationData newAnnotation=sourceAnnotation;
        if (destDefaultAnntationLocations.contains(sourceLocation)) {
          String locationRefs=sourceAnnotation.getLocationRefs();
          Integer locationRefAsInt=Integer.valueOf(locationRefs);
          if (locationRefAsInt > 0) {
            newAnnotation.setLocationRefs(String.valueOf(locationRefAsInt * -1));
          }
          report.addMessageForItem(destItem.getName(),"String_Node_Str",locationRefs);
        }
        connector.connectAnnotation(newAnnotation,newItem.getDiscrepanciesList());
        isChangesMade=true;
        int nextIndex;
        if (placeHolderAnnotationLocations.containsKey(sourceLocation)) {
          nextIndex=placeHolderAnnotationLocations.get(sourceLocation);
        }
 else {
          nextIndex=newAnnotations.length();
        }
        newAnnotation.setIndex(nextIndex);
        newAnnotations.put(nextIndex,DispoUtil.annotationToJsonObj(newAnnotation));
      }
    }
  }
  if (isChangesMade) {
    newItem.setAnnotationsList(newAnnotations);
    String newStatus=connector.getItemStatus(newItem);
    newItem.setStatus(newStatus);
  }
 else   if (!isCoverageCopy) {
    newItem=destItem;
    newItem.setGuid(sourceItem.getGuid());
  }
 else {
    report.addMessageForItem(destItem.getName(),"String_Node_Str");
    newItem=null;
  }
  return newItem;
}