Program: 65025
Project: 65025
Buggy source:
public final Object readFrom(Class<Object> type,Type genericType,Annotation[] annotations,MediaType mediaType,MultivaluedMap<String,String> httpHeaders,InputStream entityStream) throws IOException, WebApplicationException {
  try {
    Class<?> domainClass=getDomainClass(genericType);
    JAXBContext jaxbContext=getJAXBContext(domainClass,annotations,mediaType,httpHeaders);
    Unmarshaller unmarshaller=jaxbContext.createUnmarshaller();
    unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE,MediaType.APPLICATION_JSON);
    unmarshaller.setProperty(UnmarshallerProperties.JSON_ATTRIBUTE_PREFIX,attributePrefix);
    unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT,includeRoot);
    unmarshaller.setProperty(UnmarshallerProperties.JSON_NAMESPACE_PREFIX_MAPPER,namespacePrefixMapper);
    unmarshaller.setProperty(UnmarshallerProperties.JSON_NAMESPACE_SEPARATOR,namespaceSeperator);
    unmarshaller.setProperty(UnmarshallerProperties.JSON_VALUE_WRAPPER,valueWrapper);
    preReadFrom(type,genericType,annotations,mediaType,httpHeaders,unmarshaller);
    StreamSource jsonSource;
    Map<String,String> mediaTypeParameters=mediaType.getParameters();
    if (mediaTypeParameters.containsKey(CHARSET)) {
      String charSet=mediaTypeParameters.get(CHARSET);
      Reader entityReader=new InputStreamReader(entityStream,charSet);
      jsonSource=new StreamSource(entityReader);
    }
 else {
      jsonSource=new StreamSource(entityStream);
    }
    JAXBElement<?> jaxbElement=unmarshaller.unmarshal(jsonSource,domainClass);
    if (type.isAssignableFrom(JAXBElement.class)) {
      return jaxbElement;
    }
 else {
      return jaxbElement.getValue();
    }
  }
 catch (  JAXBException jaxbException) {
    throw new WebApplicationException(jaxbException);
  }
}

Fixed version (ground truth):
public final Object readFrom(Class<Object> type,Type genericType,Annotation[] annotations,MediaType mediaType,MultivaluedMap<String,String> httpHeaders,InputStream entityStream) throws IOException, WebApplicationException {
  try {
    Class<?> domainClass=getDomainClass(genericType);
    JAXBContext jaxbContext=getJAXBContext(domainClass,annotations,mediaType,httpHeaders);
    Unmarshaller unmarshaller=jaxbContext.createUnmarshaller();
    unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE,MediaType.APPLICATION_JSON);
    unmarshaller.setProperty(UnmarshallerProperties.JSON_ATTRIBUTE_PREFIX,attributePrefix);
    unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT,includeRoot);
    unmarshaller.setProperty(UnmarshallerProperties.JSON_NAMESPACE_PREFIX_MAPPER,namespacePrefixMapper);
    unmarshaller.setProperty(UnmarshallerProperties.JSON_NAMESPACE_SEPARATOR,namespaceSeperator);
    unmarshaller.setProperty(UnmarshallerProperties.JSON_VALUE_WRAPPER,valueWrapper);
    preReadFrom(type,genericType,annotations,mediaType,httpHeaders,unmarshaller);
    StreamSource jsonSource;
    Map<String,String> mediaTypeParameters=mediaType.getParameters();
    if (mediaTypeParameters.containsKey(CHARSET)) {
      String charSet=mediaTypeParameters.get(CHARSET);
      Reader entityReader=new InputStreamReader(entityStream,charSet);
      jsonSource=new StreamSource(entityReader);
    }
 else {
      jsonSource=new StreamSource(entityStream);
    }
    JAXBElement<?> jaxbElement=unmarshaller.unmarshal(jsonSource,domainClass);
    if (type.isAssignableFrom(JAXBElement.class)) {
      return jaxbElement;
    }
 else {
      Object value=jaxbElement.getValue();
      if (value instanceof ArrayList) {
        if (type.isAssignableFrom(value.getClass())) {
          return value;
        }
        ContainerPolicy containerPolicy=ContainerPolicy.buildPolicyFor(type);
        Object container=containerPolicy.containerInstance();
        for (        Object element : (Collection)value) {
          containerPolicy.addInto(element,container,null);
        }
        return container;
      }
 else {
        return value;
      }
    }
  }
 catch (  JAXBException jaxbException) {
    throw new WebApplicationException(jaxbException);
  }
}