Program: 64366
Project: 64366
Buggy source:
/** 
 * Marshall an entity to either JSON or XML
 * @param object
 * @param mediaType
 * @param output
 * @param sendRelationships if this is set to true, relationships will be sent as links instead of sending the actual objects in the relationships
 * @throws JAXBException
 */
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) public void marshallEntity(Object object,MediaType mediaType,OutputStream output,boolean sendRelationships) throws JAXBException {
  if (sendRelationships) {
    preMarshallEntity(object);
  }
  Marshaller marshaller=getJAXBContext().createMarshaller();
  marshaller.setProperty(MarshallerProperties.MEDIA_TYPE,mediaType.toString());
  marshaller.setProperty(MarshallerProperties.JSON_INCLUDE_ROOT,false);
  marshaller.setAdapter(new LinkAdapter(getBaseURI().toString(),this));
  marshaller.setAdapter(new RelationshipLinkAdapter(getBaseURI().toString(),this));
  for (  XmlAdapter adapter : getAdapters()) {
    marshaller.setAdapter(adapter);
  }
  if (mediaType == MediaType.APPLICATION_XML_TYPE && object instanceof List) {
    marshaller.setProperty(Marshaller.JAXB_FRAGMENT,true);
    XMLOutputFactory outputFactory=XMLOutputFactory.newFactory();
    XMLStreamWriter writer=null;
    try {
      writer=outputFactory.createXMLStreamWriter(output);
      writer.writeStartDocument();
      writer.writeStartElement(ConfigDefaults.JPARS_LIST_GROUPING_NAME);
      for (      Object o : (List<Object>)object) {
        marshaller.marshal(o,writer);
      }
      writer.writeEndDocument();
      postMarshallEntity(object);
    }
 catch (    Exception e) {
      e.printStackTrace();
      throw new JPARSException(e.toString());
    }
  }
 else {
    marshaller.marshal(object,output);
    postMarshallEntity(object);
  }
}

Fixed version (ground truth):
/** 
 * Marshall an entity to either JSON or XML
 * @param object
 * @param mediaType
 * @param output
 * @param sendRelationships if this is set to true, relationships will be sent as links instead of sending the actual objects in the relationships
 * @throws JAXBException
 */
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) public void marshallEntity(Object object,MediaType mediaType,OutputStream output,boolean sendRelationships) throws JAXBException {
  if (sendRelationships) {
    preMarshallEntity(object);
  }
  Marshaller marshaller=getJAXBContext().createMarshaller();
  marshaller.setProperty(MarshallerProperties.MEDIA_TYPE,mediaType.toString());
  marshaller.setProperty(MarshallerProperties.JSON_INCLUDE_ROOT,false);
  marshaller.setProperty(MarshallerProperties.JSON_REDUCE_ANY_ARRAYS,true);
  marshaller.setAdapter(new LinkAdapter(getBaseURI().toString(),this));
  marshaller.setAdapter(new RelationshipLinkAdapter(getBaseURI().toString(),this));
  for (  XmlAdapter adapter : getAdapters()) {
    marshaller.setAdapter(adapter);
  }
  if (mediaType == MediaType.APPLICATION_XML_TYPE && object instanceof List) {
    marshaller.setProperty(Marshaller.JAXB_FRAGMENT,true);
    XMLOutputFactory outputFactory=XMLOutputFactory.newFactory();
    XMLStreamWriter writer=null;
    try {
      writer=outputFactory.createXMLStreamWriter(output);
      writer.writeStartDocument();
      writer.writeStartElement(ConfigDefaults.JPARS_LIST_GROUPING_NAME);
      for (      Object o : (List<Object>)object) {
        marshaller.marshal(o,writer);
      }
      writer.writeEndDocument();
      postMarshallEntity(object);
    }
 catch (    Exception e) {
      e.printStackTrace();
      throw new JPARSException(e.toString());
    }
  }
 else {
    marshaller.marshal(object,output);
    postMarshallEntity(object);
  }
}