Program: 64204
Project: 64204
Buggy source:
protected Response setOrAddAttribute(String version,String persistenceUnit,String type,String key,String attribute,HttpHeaders hh,UriInfo ui,URI baseURI,InputStream in){
  PersistenceContext app=getPersistenceContext(persistenceUnit,baseURI,version,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)getMatrixParameters(ui,attribute).get(MatrixParameters.JPARS_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(getMatrixParameters(ui,persistenceUnit),type,id,getQueryParameters(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 version,String persistenceUnit,String type,String key,String attribute,HttpHeaders hh,UriInfo ui,URI baseURI,InputStream in){
  PersistenceContext app=getPersistenceContext(persistenceUnit,baseURI,version,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=getRelationshipPartner(getMatrixParameters(ui,attribute),getQueryParameters(ui));
  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(getMatrixParameters(ui,persistenceUnit),type,id,getQueryParameters(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();
  }
}