Program: 85968
Project: 85968
Buggy source:
/** 
 * Convert a Document Revision to a JSON Builder.
 * @param doc           Document to pass to JSON
 * @param contentInputs Map of binary resources content
 * @return A JSON Builder to index
 */
protected static XContentBuilder documentRevisionToJSON(DocumentIteration doc,Map<String,String> contentInputs){
  try {
    XContentBuilder tmp=XContentFactory.jsonBuilder().startObject();
    setField(tmp,WORKSPACEID_KEY,doc.getWorkspaceId(),0.6f);
    setField(tmp,"String_Node_Str",doc.getDocumentRevision().getDocumentMasterId(),4.75f);
    setField(tmp,"String_Node_Str",doc.getDocumentRevision().getTitle(),5f);
    setField(tmp,VERSION_KEY,doc.getDocumentVersion(),0.10f);
    tmp.startArray(ITERATIONS_KEY);
    for (    DocumentIteration iteration : doc.getDocumentRevision().getDocumentIterations()) {
      tmp.startObject();
      setField(tmp,"String_Node_Str","String_Node_Str" + iteration.getIteration(),0.10f);
      if (doc.getAuthor() != null) {
        tmp.startObject(AUTHOR_KEY);
        setField(tmp,AUTHOR_LOGIN_KEY,iteration.getAuthor().getLogin(),0.6f);
        setField(tmp,AUTHOR_NAME_KEY,iteration.getAuthor().getName(),0.6f);
        tmp.endObject();
      }
      setField(tmp,TYPE_KEY,iteration.getDocumentRevision().getDocumentMaster().getType(),2f);
      setField(tmp,CREATION_DATE_KEY,iteration.getDocumentRevision().getCreationDate(),0.4f);
      setField(tmp,MODIFICATION_DATE_KEY,iteration.getModificationDate(),0.4f);
      setField(tmp,"String_Node_Str",iteration.getDocumentRevision().getDescription(),2f);
      setField(tmp,"String_Node_Str",iteration.getRevisionNote(),0.5f);
      setField(tmp,"String_Node_Str",iteration.getDocumentRevision().getWorkflow(),0.5f);
      setField(tmp,"String_Node_Str",iteration.getDocumentRevision().getLocation().getShortName(),0.5f);
      if (!iteration.getDocumentRevision().getTags().isEmpty()) {
        tmp.startArray("String_Node_Str");
        for (        Tag tag : doc.getDocumentRevision().getTags()) {
          tmp.value(tag.getLabel());
        }
        tmp.endArray();
      }
      if (!iteration.getInstanceAttributes().isEmpty()) {
        tmp.startObject("String_Node_Str");
        Collection<InstanceAttribute> listAttr=iteration.getInstanceAttributes();
        for (        InstanceAttribute attr : listAttr) {
          setField(tmp,attr.getNameWithoutWhiteSpace(),"String_Node_Str" + attr.getValue(),0.6f);
        }
        tmp.endObject();
      }
      if (!iteration.getAttachedFiles().isEmpty()) {
        tmp.startObject("String_Node_Str");
        for (        Map.Entry<String,String> contentInput : contentInputs.entrySet()) {
          tmp.startObject(contentInput.getKey());
          setField(tmp,AUTHOR_NAME_KEY,contentInput.getKey(),0.8f);
          setField(tmp,"String_Node_Str",contentInput.getValue(),0.6f);
          tmp.endObject();
        }
        tmp.endObject();
      }
      tmp.endObject();
    }
    tmp.endArray();
    tmp.endObject();
    return tmp;
  }
 catch (  IOException e) {
    LOGGER.log(Level.WARNING,"String_Node_Str" + doc + "String_Node_Str",e);
    return null;
  }
}

Fixed version (ground truth):
/** 
 * Convert a Document Revision to a JSON Builder.
 * @param doc           Document to pass to JSON
 * @param contentInputs Map of binary resources content
 * @return A JSON Builder to index
 */
protected static XContentBuilder documentRevisionToJSON(DocumentIteration doc,Map<String,String> contentInputs){
  try {
    XContentBuilder tmp=XContentFactory.jsonBuilder().startObject();
    setField(tmp,WORKSPACE_ID_KEY,doc.getWorkspaceId(),0.6f);
    setField(tmp,DOCUMENT_ID_KEY,doc.getDocumentRevision().getDocumentMasterId(),4.75f);
    setField(tmp,TITLE_KEY,doc.getDocumentRevision().getTitle(),5f);
    setField(tmp,VERSION_KEY,doc.getDocumentVersion(),0.10f);
    tmp.startArray(ITERATIONS_KEY);
    for (    DocumentIteration iteration : doc.getDocumentRevision().getDocumentIterations()) {
      tmp.startObject();
      setField(tmp,ITERATION_KEY,"String_Node_Str" + iteration.getIteration(),0.10f);
      if (doc.getAuthor() != null) {
        tmp.startObject(AUTHOR_KEY);
        setField(tmp,AUTHOR_LOGIN_KEY,iteration.getAuthor().getLogin(),0.6f);
        setField(tmp,AUTHOR_NAME_KEY,iteration.getAuthor().getName(),0.6f);
        tmp.endObject();
      }
      setField(tmp,TYPE_KEY,iteration.getDocumentRevision().getDocumentMaster().getType(),2f);
      setField(tmp,CREATION_DATE_KEY,iteration.getDocumentRevision().getCreationDate(),0.4f);
      setField(tmp,MODIFICATION_DATE_KEY,iteration.getModificationDate(),0.4f);
      setField(tmp,DESCRIPTION_KEY,iteration.getDocumentRevision().getDescription(),2f);
      setField(tmp,REVISION_NOTE_KEY,iteration.getRevisionNote(),0.5f);
      setField(tmp,WORKFLOW_KEY,iteration.getDocumentRevision().getWorkflow(),0.5f);
      setField(tmp,FOLDER_KEY,iteration.getDocumentRevision().getLocation().getShortName(),0.5f);
      if (!iteration.getDocumentRevision().getTags().isEmpty()) {
        tmp.startArray(TAGS_KEY);
        for (        Tag tag : doc.getDocumentRevision().getTags()) {
          tmp.value(tag.getLabel());
        }
        tmp.endArray();
      }
      if (!iteration.getInstanceAttributes().isEmpty()) {
        tmp.startObject(ATTRIBUTES_KEY);
        Collection<InstanceAttribute> listAttr=iteration.getInstanceAttributes();
        for (        InstanceAttribute attr : listAttr) {
          setField(tmp,attr.getNameWithoutWhiteSpace(),"String_Node_Str" + attr.getValue(),0.6f);
        }
        tmp.endObject();
      }
      if (!iteration.getAttachedFiles().isEmpty()) {
        tmp.startObject(FILES_KEY);
        for (        Map.Entry<String,String> contentInput : contentInputs.entrySet()) {
          tmp.startObject(contentInput.getKey());
          setField(tmp,AUTHOR_NAME_KEY,contentInput.getKey(),0.8f);
          setField(tmp,CONTENT_KEY,contentInput.getValue(),0.6f);
          tmp.endObject();
        }
        tmp.endObject();
      }
      tmp.endObject();
    }
    tmp.endArray();
    tmp.endObject();
    return tmp;
  }
 catch (  IOException e) {
    LOGGER.log(Level.WARNING,"String_Node_Str" + doc + "String_Node_Str",e);
    return null;
  }
}