Program: 64190
Project: 64190
Buggy source:
/** 
 * @see javax.ws.rs.ext.MessageBodyWriter#writeTo(java.lang.Object,java.lang.Class,java.lang.reflect.Type,java.lang.annotation.Annotation[],javax.ws.rs.core.MediaType,javax.ws.rs.core.MultivaluedMap,java.io.OutputStream)
 */
public final void writeTo(Object object,Class<?> type,Type genericType,Annotation[] annotations,MediaType mediaType,MultivaluedMap<String,Object> httpHeaders,OutputStream entityStream) throws IOException, WebApplicationException {
  try {
    Class<?> domainClass=getDomainClass(genericType);
    JAXBContext jaxbContext=getJAXBContext(domainClass,annotations,mediaType,httpHeaders);
    Marshaller marshaller=jaxbContext.createMarshaller();
    marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,formattedOutput);
    marshaller.setProperty(MarshallerProperties.MEDIA_TYPE,MediaType.APPLICATION_JSON);
    marshaller.setProperty(MarshallerProperties.JSON_ATTRIBUTE_PREFIX,attributePrefix);
    marshaller.setProperty(MarshallerProperties.JSON_INCLUDE_ROOT,includeRoot);
    marshaller.setProperty(MarshallerProperties.JSON_MARSHAL_EMPTY_COLLECTIONS,marshalEmptyCollections);
    marshaller.setProperty(MarshallerProperties.JSON_NAMESPACE_SEPARATOR,namespaceSeperator);
    if (null != valueWrapper) {
      marshaller.setProperty(MarshallerProperties.JSON_VALUE_WRAPPER,valueWrapper);
    }
    marshaller.setProperty(MarshallerProperties.NAMESPACE_PREFIX_MAPPER,namespacePrefixMapper);
    Map<String,String> mediaTypeParameters=mediaType.getParameters();
    if (mediaTypeParameters.containsKey(CHARSET)) {
      String charSet=mediaTypeParameters.get(CHARSET);
      marshaller.setProperty(Marshaller.JAXB_ENCODING,charSet);
    }
    preWriteTo(object,type,genericType,annotations,mediaType,httpHeaders,marshaller);
    marshaller.marshal(object,entityStream);
  }
 catch (  JAXBException jaxbException) {
    throw new WebApplicationException(jaxbException);
  }
}

Fixed version (ground truth):
/** 
 * @see javax.ws.rs.ext.MessageBodyWriter#writeTo(java.lang.Object,java.lang.Class,java.lang.reflect.Type,java.lang.annotation.Annotation[],javax.ws.rs.core.MediaType,javax.ws.rs.core.MultivaluedMap,java.io.OutputStream)
 */
public void writeTo(Object object,Class<?> type,Type genericType,Annotation[] annotations,MediaType mediaType,MultivaluedMap<String,Object> httpHeaders,OutputStream entityStream) throws IOException, WebApplicationException {
  try {
    if (null == genericType) {
      genericType=type;
    }
    Class<?> domainClass=getDomainClass(genericType);
    JAXBContext jaxbContext=getJAXBContext(domainClass,annotations,mediaType,httpHeaders);
    Marshaller marshaller=jaxbContext.createMarshaller();
    marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,formattedOutput);
    marshaller.setProperty(MarshallerProperties.MEDIA_TYPE,MediaType.APPLICATION_JSON);
    marshaller.setProperty(MarshallerProperties.JSON_ATTRIBUTE_PREFIX,attributePrefix);
    marshaller.setProperty(MarshallerProperties.JSON_INCLUDE_ROOT,includeRoot);
    marshaller.setProperty(MarshallerProperties.JSON_MARSHAL_EMPTY_COLLECTIONS,marshalEmptyCollections);
    marshaller.setProperty(MarshallerProperties.JSON_NAMESPACE_SEPARATOR,namespaceSeperator);
    if (null != valueWrapper) {
      marshaller.setProperty(MarshallerProperties.JSON_VALUE_WRAPPER,valueWrapper);
    }
    marshaller.setProperty(MarshallerProperties.NAMESPACE_PREFIX_MAPPER,namespacePrefixMapper);
    Map<String,String> mediaTypeParameters=mediaType.getParameters();
    if (mediaTypeParameters.containsKey(CHARSET)) {
      String charSet=mediaTypeParameters.get(CHARSET);
      marshaller.setProperty(Marshaller.JAXB_ENCODING,charSet);
    }
    preWriteTo(object,type,genericType,annotations,mediaType,httpHeaders,marshaller);
    marshaller.marshal(object,entityStream);
  }
 catch (  JAXBException jaxbException) {
    throw new WebApplicationException(jaxbException);
  }
}