Program: 188925
Project: 188925
Buggy source:
/** 
 * {@inheritDoc} 
 */
@Override @Put public Representation put(Representation entity){
  authenticate();
  Representation representation=null;
  Lane newLane=null;
  JaxbObject<Lane> jo=new JaxbObject<Lane>();
  try {
    String text=entity.getText();
    newLane=(Lane)XmlTools.unMarshal(jo,new Lane(),text);
  }
 catch (  SAXException ex) {
    ex.printStackTrace();
    throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST,ex);
  }
catch (  IOException e) {
    e.printStackTrace();
    throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST,e);
  }
  try {
    LaneService fs=BeanFactory.getLaneServiceBean();
    Lane lane=(Lane)testIfNull(fs.findByID(newLane.getLaneId()));
    lane.givesPermission(registration);
    String name=newLane.getName();
    String desc=newLane.getDescription();
    Integer laneIndex=newLane.getLaneIndex();
    String cycleDescriptor=newLane.getCycleDescriptor();
    Boolean skip=newLane.getSkip();
    String tags=newLane.getTags();
    String regions=newLane.getRegions();
    Sample sample=newLane.getSample();
    Registration owner=newLane.getOwner();
    Set<LaneAttribute> newAttributes=newLane.getLaneAttributes();
    if (name != null) {
      lane.setName(name);
    }
    if (desc != null) {
      lane.setDescription(desc);
    }
    if (laneIndex != null) {
      lane.setLaneIndex(laneIndex);
    }
    if (cycleDescriptor != null) {
      lane.setCycleDescriptor(cycleDescriptor);
    }
    if (skip != null) {
      lane.setSkip(skip);
    }
    if (tags != null) {
      lane.setTags(tags);
    }
    if (regions != null) {
      lane.setRegions(regions);
    }
    if (sample != null) {
      SampleService ss=BeanFactory.getSampleServiceBean();
      Sample newSample=ss.findByID(sample.getSampleId());
      if (newSample != null && newSample.givesPermission(registration)) {
        lane.setSample(newSample);
      }
 else       if (newSample == null) {
        Log.info("String_Node_Str" + sample);
      }
    }
    if (owner != null) {
      RegistrationService rs=BeanFactory.getRegistrationServiceBean();
      Registration newReg=rs.findByEmailAddress(owner.getEmailAddress());
      if (newReg != null) {
        lane.setOwner(newReg);
      }
 else {
        Log.info("String_Node_Str" + owner);
      }
    }
 else     if (lane.getOwner() == null) {
      lane.setOwner(registration);
    }
    logger.debug("String_Node_Str" + newAttributes);
    if (newAttributes != null) {
      lane.getLaneAttributes().clear();
      for (      LaneAttribute la : newAttributes) {
        la.setLane(lane);
        lane.getLaneAttributes().add(la);
      }
    }
    fs.update(registration,lane);
    Hibernate3DtoCopier copier=new Hibernate3DtoCopier();
    Lane detachedLane=copier.hibernate2dto(Lane.class,lane);
    Document line=XmlTools.marshalToDocument(jo,detachedLane);
    representation=XmlTools.getRepresentation(line);
    getResponse().setEntity(representation);
    getResponse().setLocationRef(getRequest().getRootRef() + "String_Node_Str" + detachedLane.getSwAccession());
    getResponse().setStatus(Status.SUCCESS_CREATED);
  }
 catch (  SecurityException e) {
    getResponse().setStatus(Status.CLIENT_ERROR_FORBIDDEN,e.getMessage());
  }
catch (  Exception e) {
    e.printStackTrace();
    getResponse().setStatus(Status.SERVER_ERROR_INTERNAL,e.getMessage());
  }
  return representation;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
@Override @Put public Representation put(Representation entity){
  authenticate();
  Representation representation=null;
  Lane newLane=null;
  JaxbObject<Lane> jo=new JaxbObject<Lane>();
  try {
    String text=entity.getText();
    newLane=(Lane)XmlTools.unMarshal(jo,new Lane(),text);
  }
 catch (  SAXException ex) {
    ex.printStackTrace();
    throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST,ex);
  }
catch (  IOException e) {
    e.printStackTrace();
    throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST,e);
  }
  try {
    LaneService fs=BeanFactory.getLaneServiceBean();
    Lane lane=(Lane)testIfNull(fs.findByID(newLane.getLaneId()));
    lane.givesPermission(registration);
    String name=newLane.getName();
    String desc=newLane.getDescription();
    Integer laneIndex=newLane.getLaneIndex();
    String cycleDescriptor=newLane.getCycleDescriptor();
    Boolean skip=newLane.getSkip();
    String tags=newLane.getTags();
    String regions=newLane.getRegions();
    Sample sample=newLane.getSample();
    Registration owner=newLane.getOwner();
    Set<LaneAttribute> newAttributes=newLane.getLaneAttributes();
    if (name != null) {
      lane.setName(name);
    }
    if (desc != null) {
      lane.setDescription(desc);
    }
    if (laneIndex != null) {
      lane.setLaneIndex(laneIndex);
    }
    if (cycleDescriptor != null) {
      lane.setCycleDescriptor(cycleDescriptor);
    }
    if (skip != null) {
      lane.setSkip(skip);
    }
    if (tags != null) {
      lane.setTags(tags);
    }
    if (regions != null) {
      lane.setRegions(regions);
    }
    if (sample != null) {
      SampleService ss=BeanFactory.getSampleServiceBean();
      Sample newSample=ss.findByID(sample.getSampleId());
      if (newSample != null && newSample.givesPermission(registration)) {
        lane.setSample(newSample);
      }
 else       if (newSample == null) {
        Log.info("String_Node_Str" + sample);
      }
    }
    if (owner != null) {
      RegistrationService rs=BeanFactory.getRegistrationServiceBean();
      Registration newReg=rs.findByEmailAddress(owner.getEmailAddress());
      if (newReg != null) {
        lane.setOwner(newReg);
      }
 else {
        Log.info("String_Node_Str" + owner);
      }
    }
 else     if (lane.getOwner() == null) {
      lane.setOwner(registration);
    }
    logger.debug("String_Node_Str" + newAttributes);
    if (newAttributes != null) {
      for (      LaneAttribute la : newAttributes) {
        la.setLane(lane);
        lane.getLaneAttributes().add(la);
      }
    }
    fs.update(registration,lane);
    Hibernate3DtoCopier copier=new Hibernate3DtoCopier();
    Lane detachedLane=copier.hibernate2dto(Lane.class,lane);
    Document line=XmlTools.marshalToDocument(jo,detachedLane);
    representation=XmlTools.getRepresentation(line);
    getResponse().setEntity(representation);
    getResponse().setLocationRef(getRequest().getRootRef() + "String_Node_Str" + detachedLane.getSwAccession());
    getResponse().setStatus(Status.SUCCESS_CREATED);
  }
 catch (  SecurityException e) {
    getResponse().setStatus(Status.CLIENT_ERROR_FORBIDDEN,e.getMessage());
  }
catch (  Exception e) {
    e.printStackTrace();
    getResponse().setStatus(Status.SERVER_ERROR_INTERNAL,e.getMessage());
  }
  return representation;
}