Program: 64594
Project: 64594
Buggy source:
protected Response setOrAddAttribute(String persistenceUnit,String type,String key,String attribute,HttpHeaders hh,UriInfo ui,URI baseURI,InputStream in){
  PersistenceContext app=getPersistenceFactory().get(persistenceUnit,baseURI,null);
  if (app == null || app.getClass(type) == null) {
    if (app == null) {
      JPARSLogger.fine("String_Node_Str",new Object[]{persistenceUnit});
    }
 else {
      JPARSLogger.fine("String_Node_Str",new Object[]{type,persistenceUnit});
    }
    return Response.status(Status.NOT_FOUND).build();
  }
  Map<String,String> discriminators=getParameterMap(ui,persistenceUnit);
  Object id=IdHelper.buildId(app,type,key,discriminators);
  Object entity=null;
  String partner=(String)getParameterMap(ui,attribute).get(RELATIONSHIP_PARTNER);
  try {
    ClassDescriptor descriptor=app.getDescriptor(type);
    DatabaseMapping mapping=(DatabaseMapping)descriptor.getMappingForAttributeName(attribute);
    if (!mapping.isForeignReferenceMapping()) {
      JPARSLogger.fine("String_Node_Str",new Object[]{attribute,type,key,persistenceUnit});
      return Response.status(Status.NOT_FOUND).build();
    }
    entity=app.unmarshalEntity(((ForeignReferenceMapping)mapping).getReferenceDescriptor().getAlias(),mediaType(hh.getAcceptableMediaTypes()),in);
  }
 catch (  JAXBException e) {
    JPARSLogger.fine("String_Node_Str",new Object[]{type,persistenceUnit,e.toString()});
    return Response.status(Status.BAD_REQUEST).build();
  }
  Object result=app.updateOrAddAttribute(getParameterMap(ui,persistenceUnit),type,id,getHintMap(ui),attribute,entity,partner);
  if (result == null) {
    JPARSLogger.fine("String_Node_Str",new Object[]{attribute,type,key,persistenceUnit});
    return Response.status(Status.NOT_FOUND).build();
  }
 else {
    return Response.ok(new StreamingOutputMarshaller(app,result,hh.getAcceptableMediaTypes())).build();
  }
}

Fixed version (ground truth):
protected Response setOrAddAttribute(String persistenceUnit,String type,String key,String attribute,HttpHeaders hh,UriInfo ui,URI baseURI,InputStream in){
  PersistenceContext app=getPersistenceFactory().get(persistenceUnit,baseURI,null);
  if (app == null || app.getClass(type) == null) {
    if (app == null) {
      JPARSLogger.fine("String_Node_Str",new Object[]{persistenceUnit});
    }
 else {
      JPARSLogger.fine("String_Node_Str",new Object[]{type,persistenceUnit});
    }
    return Response.status(Status.NOT_FOUND).build();
  }
  Object id=IdHelper.buildId(app,type,key);
  Object entity=null;
  String partner=(String)getParameterMap(ui,attribute).get(RELATIONSHIP_PARTNER);
  try {
    ClassDescriptor descriptor=app.getDescriptor(type);
    DatabaseMapping mapping=(DatabaseMapping)descriptor.getMappingForAttributeName(attribute);
    if (!mapping.isForeignReferenceMapping()) {
      JPARSLogger.fine("String_Node_Str",new Object[]{attribute,type,key,persistenceUnit});
      return Response.status(Status.NOT_FOUND).build();
    }
    entity=app.unmarshalEntity(((ForeignReferenceMapping)mapping).getReferenceDescriptor().getAlias(),mediaType(hh.getAcceptableMediaTypes()),in);
  }
 catch (  JAXBException e) {
    JPARSLogger.fine("String_Node_Str",new Object[]{type,persistenceUnit,e.toString()});
    return Response.status(Status.BAD_REQUEST).build();
  }
  Object result=app.updateOrAddAttribute(getParameterMap(ui,persistenceUnit),type,id,getHintMap(ui),attribute,entity,partner);
  if (result == null) {
    JPARSLogger.fine("String_Node_Str",new Object[]{attribute,type,key,persistenceUnit});
    return Response.status(Status.NOT_FOUND).build();
  }
 else {
    return Response.ok(new StreamingOutputMarshaller(app,result,hh.getAcceptableMediaTypes())).build();
  }
}