Program: 63611
Project: 63611
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 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.JSON_WRAPPER_AS_ARRAY_NAME,wrapperAsArrayName);
    marshaller.setProperty(MarshallerProperties.NAMESPACE_PREFIX_MAPPER,namespacePrefixMapper);
    Map<String,String> mediaTypeParameters=null;
    if (null != mediaType) {
      mediaTypeParameters=mediaType.getParameters();
    }
    if (null != mediaTypeParameters && 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.JSON_WRAPPER_AS_ARRAY_NAME,wrapperAsArrayName);
    marshaller.setProperty(MarshallerProperties.NAMESPACE_PREFIX_MAPPER,namespacePrefixMapper);
    Map<String,String> mediaTypeParameters=null;
    if (null != mediaType) {
      mediaTypeParameters=mediaType.getParameters();
    }
    if (null != mediaTypeParameters && mediaTypeParameters.containsKey(CHARSET)) {
      String charSet=mediaTypeParameters.get(CHARSET);
      marshaller.setProperty(Marshaller.JAXB_ENCODING,charSet);
    }
    preWriteTo(object,type,genericType,annotations,mediaType,httpHeaders,marshaller);
    if (domainClass.getPackage().getName().startsWith("String_Node_Str") && !(List.class.isAssignableFrom(type) || type.isArray())) {
      object=new JAXBElement(new QName((String)marshaller.getProperty(MarshallerProperties.JSON_VALUE_WRAPPER)),domainClass,object);
    }
    marshaller.marshal(object,entityStream);
  }
 catch (  JAXBException jaxbException) {
    throw new WebApplicationException(jaxbException);
  }
}