Program: 188927
Project: 188927
Buggy source:
/** 
 * {@inheritDoc} 
 */
@Override @Put public Representation put(Representation entity){
  authenticate();
  Representation representation=null;
  try {
    JaxbObject<Sample> jo=new JaxbObject<Sample>();
    String text=entity.getText();
    Sample o=null;
    try {
      o=(Sample)XmlTools.unMarshal(jo,new Sample(),text);
    }
 catch (    SAXException ex) {
      throw new ResourceException(Status.CLIENT_ERROR_UNPROCESSABLE_ENTITY,ex);
    }
    SampleService service=BeanFactory.getSampleServiceBean();
    Sample sample=(Sample)testIfNull(service.findByID(o.getSampleId()));
    sample.givesPermission(registration);
    String anonymizedName=o.getAnonymizedName();
    String individualName=o.getIndividualName();
    Integer swAccession=o.getSwAccession();
    String name=o.getName();
    String title=o.getTitle();
    String alias=o.getAlias();
    String description=o.getDescription();
    String type=o.getType();
    String tags=o.getTags();
    String adapters=o.getAdapters();
    String regions=o.getRegions();
    Integer expectedNumRuns=o.getExpectedNumRuns();
    Integer expectedNumSpots=o.getExpectedNumSpots();
    Integer expectedNumReads=o.getExpectedNumReads();
    Boolean skip=o.getSkip();
    Boolean isSelected=o.getIsSelected();
    Boolean isHasFile=o.getIsHasFile();
    Integer countFile=o.getCountFile();
    if (null != anonymizedName)     sample.setAnonymizedName(anonymizedName);
    if (null != individualName)     sample.setIndividualName(individualName);
    if (null != swAccession)     sample.setSwAccession(swAccession);
    if (null != name)     sample.setName(name);
    if (null != title)     sample.setTitle(title);
    if (null != alias)     sample.setAlias(alias);
    if (null != description)     sample.setDescription(description);
    if (null != type)     sample.setType(type);
    if (null != tags)     sample.setTags(tags);
    if (null != adapters)     sample.setAdapters(adapters);
    if (null != regions)     sample.setRegions(regions);
    if (null != expectedNumRuns)     sample.setExpectedNumRuns(expectedNumRuns);
    if (null != expectedNumSpots)     sample.setExpectedNumSpots(expectedNumSpots);
    if (null != expectedNumReads)     sample.setExpectedNumReads(expectedNumReads);
    if (null != skip)     sample.setSkip(skip);
    if (null != isSelected)     sample.setIsSelected(isSelected);
    if (null != isHasFile)     sample.setIsHasFile(isHasFile);
    if (null != countFile)     sample.setCountFile(countFile);
    if (null != o.getSampleAttributes()) {
      sample.getSampleAttributes().clear();
      for (      SampleAttribute sa : o.getSampleAttributes()) {
        sa.setSample(sample);
        sample.getSampleAttributes().add(sa);
      }
    }
    if (null != o.getParents()) {
      SampleService ss=BeanFactory.getSampleServiceBean();
      Set<Sample> parents=new HashSet<Sample>();
      for (      Sample s : o.getParents()) {
        parents.add(ss.findByID(s.getSampleId()));
      }
      sample.setParents(parents);
    }
    if (null != o.getChildren()) {
      SampleService ss=BeanFactory.getSampleServiceBean();
      Set<Sample> children=new HashSet<Sample>();
      for (      Sample s : o.getChildren()) {
        children.add(ss.findByID(s.getSampleId()));
      }
      sample.setChildren(children);
    }
    service.update(sample);
    Hibernate3DtoCopier copier=new Hibernate3DtoCopier();
    Sample detachedSample=copier.hibernate2dto(Sample.class,sample);
    Document line=XmlTools.marshalToDocument(jo,detachedSample);
    getResponse().setEntity(XmlTools.getRepresentation(line));
    getResponse().setLocationRef(getRequest().getRootRef() + "String_Node_Str" + detachedSample.getSwAccession());
    getResponse().setStatus(Status.SUCCESS_CREATED);
  }
 catch (  SecurityException e) {
    getResponse().setStatus(Status.CLIENT_ERROR_FORBIDDEN,e);
  }
catch (  Exception e) {
    e.printStackTrace();
    getResponse().setStatus(Status.SERVER_ERROR_INTERNAL,e);
  }
  return representation;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
@Override @Put public Representation put(Representation entity){
  authenticate();
  Representation representation=null;
  try {
    JaxbObject<Sample> jo=new JaxbObject<Sample>();
    String text=entity.getText();
    Sample o=null;
    try {
      o=(Sample)XmlTools.unMarshal(jo,new Sample(),text);
    }
 catch (    SAXException ex) {
      throw new ResourceException(Status.CLIENT_ERROR_UNPROCESSABLE_ENTITY,ex);
    }
    SampleService service=BeanFactory.getSampleServiceBean();
    Sample sample=(Sample)testIfNull(service.findByID(o.getSampleId()));
    sample.givesPermission(registration);
    String anonymizedName=o.getAnonymizedName();
    String individualName=o.getIndividualName();
    Integer swAccession=o.getSwAccession();
    String name=o.getName();
    String title=o.getTitle();
    String alias=o.getAlias();
    String description=o.getDescription();
    String type=o.getType();
    String tags=o.getTags();
    String adapters=o.getAdapters();
    String regions=o.getRegions();
    Integer expectedNumRuns=o.getExpectedNumRuns();
    Integer expectedNumSpots=o.getExpectedNumSpots();
    Integer expectedNumReads=o.getExpectedNumReads();
    Boolean skip=o.getSkip();
    Boolean isSelected=o.getIsSelected();
    Boolean isHasFile=o.getIsHasFile();
    Integer countFile=o.getCountFile();
    if (null != anonymizedName)     sample.setAnonymizedName(anonymizedName);
    if (null != individualName)     sample.setIndividualName(individualName);
    if (null != swAccession)     sample.setSwAccession(swAccession);
    if (null != name)     sample.setName(name);
    if (null != title)     sample.setTitle(title);
    if (null != alias)     sample.setAlias(alias);
    if (null != description)     sample.setDescription(description);
    if (null != type)     sample.setType(type);
    if (null != tags)     sample.setTags(tags);
    if (null != adapters)     sample.setAdapters(adapters);
    if (null != regions)     sample.setRegions(regions);
    if (null != expectedNumRuns)     sample.setExpectedNumRuns(expectedNumRuns);
    if (null != expectedNumSpots)     sample.setExpectedNumSpots(expectedNumSpots);
    if (null != expectedNumReads)     sample.setExpectedNumReads(expectedNumReads);
    if (null != skip)     sample.setSkip(skip);
    if (null != isSelected)     sample.setIsSelected(isSelected);
    if (null != isHasFile)     sample.setIsHasFile(isHasFile);
    if (null != countFile)     sample.setCountFile(countFile);
    if (null != o.getSampleAttributes()) {
      for (      SampleAttribute sa : o.getSampleAttributes()) {
        sa.setSample(sample);
        sample.getSampleAttributes().add(sa);
      }
    }
    if (null != o.getParents()) {
      SampleService ss=BeanFactory.getSampleServiceBean();
      Set<Sample> parents=new HashSet<Sample>(sample.getParents());
      for (      Sample s : o.getParents()) {
        parents.add(ss.findByID(s.getSampleId()));
      }
      sample.setParents(parents);
    }
    if (null != o.getChildren()) {
      SampleService ss=BeanFactory.getSampleServiceBean();
      Set<Sample> children=new HashSet<Sample>(sample.getChildren());
      for (      Sample s : o.getChildren()) {
        children.add(ss.findByID(s.getSampleId()));
      }
      sample.setChildren(children);
    }
    service.update(sample);
    Hibernate3DtoCopier copier=new Hibernate3DtoCopier();
    Sample detachedSample=copier.hibernate2dto(Sample.class,sample);
    Document line=XmlTools.marshalToDocument(jo,detachedSample);
    getResponse().setEntity(XmlTools.getRepresentation(line));
    getResponse().setLocationRef(getRequest().getRootRef() + "String_Node_Str" + detachedSample.getSwAccession());
    getResponse().setStatus(Status.SUCCESS_CREATED);
  }
 catch (  SecurityException e) {
    getResponse().setStatus(Status.CLIENT_ERROR_FORBIDDEN,e);
  }
catch (  Exception e) {
    e.printStackTrace();
    getResponse().setStatus(Status.SERVER_ERROR_INTERNAL,e);
  }
  return representation;
}