Program: 89665
Project: 89665
Buggy source:
/** 
 * Update an existing harvest definition with new info.
 * @param hd An updated harvest definition
 * @see HarvestDefinitionDAO#update(HarvestDefinition)
 */
public synchronized void update(HarvestDefinition hd){
  ArgumentNotValid.checkNotNull(hd,"String_Node_Str");
  if (hd.getOid() == null || !exists(hd.getOid())) {
    final String message="String_Node_Str" + "String_Node_Str" + hd.getName() + "String_Node_Str";
    log.debug(message);
    throw new PermissionDenied(message);
  }
  Connection c=HarvestDBConnection.get();
  PreparedStatement s=null;
  try {
    c.setAutoCommit(false);
    s=c.prepareStatement("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
    DBUtils.setName(s,1,hd,Constants.MAX_NAME_SIZE);
    DBUtils.setComments(s,2,hd,Constants.MAX_COMMENT_SIZE);
    s.setInt(3,hd.getNumEvents());
    s.setTimestamp(4,new Timestamp(hd.getSubmissionDate().getTime()));
    s.setBoolean(5,hd.getActive());
    long nextEdition=hd.getEdition() + 1;
    s.setLong(6,nextEdition);
    s.setLong(7,hd.getOid());
    s.setLong(8,hd.getEdition());
    int rows=s.executeUpdate();
    if (rows == 0) {
      String message="String_Node_Str" + hd + "String_Node_Str"+ hd.getEdition()+ "String_Node_Str";
      log.debug(message);
      throw new PermissionDenied(message);
    }
    s.close();
    if (hd instanceof FullHarvest) {
      FullHarvest fh=(FullHarvest)hd;
      s=c.prepareStatement("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
      if (fh.getPreviousHarvestDefinition() != null) {
        s.setLong(1,fh.getPreviousHarvestDefinition().getOid());
      }
 else {
        s.setNull(1,Types.BIGINT);
      }
      s.setLong(2,fh.getMaxCountObjects());
      s.setLong(3,fh.getMaxBytes());
      s.setLong(4,fh.getMaxJobRunningTime());
      s.setBoolean(5,fh.getIndexReady());
      s.setLong(6,fh.getOid());
      rows=s.executeUpdate();
      log.debug(rows + "String_Node_Str");
    }
 else     if (hd instanceof PartialHarvest) {
      PartialHarvest ph=(PartialHarvest)hd;
      s=c.prepareStatement("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
      s.setString(1,ph.getSchedule().getName());
      DBUtils.setDateMaybeNull(s,2,ph.getNextDate());
      s.setLong(3,ph.getOid());
      rows=s.executeUpdate();
      log.debug(rows + "String_Node_Str");
      s.close();
      createHarvestConfigsEntries(c,ph,ph.getOid());
    }
 else {
      String message="String_Node_Str" + hd + "String_Node_Str"+ hd.getClass();
      log.warn(message);
      throw new ArgumentNotValid(message);
    }
    c.commit();
    hd.setEdition(nextEdition);
  }
 catch (  SQLException e) {
    throw new IOFailure("String_Node_Str" + hd + "String_Node_Str"+ ExceptionUtils.getSQLExceptionCause(e),e);
  }
 finally {
    DBUtils.rollbackIfNeeded(c,"String_Node_Str",hd);
    HarvestDBConnection.release(c);
  }
}

Fixed version (ground truth):
/** 
 * Update an existing harvest definition with new info.
 * @param hd An updated harvest definition
 * @see HarvestDefinitionDAO#update(HarvestDefinition)
 */
public synchronized void update(HarvestDefinition hd){
  ArgumentNotValid.checkNotNull(hd,"String_Node_Str");
  if (hd.getOid() == null || !exists(hd.getOid())) {
    final String message="String_Node_Str" + "String_Node_Str" + hd.getName() + "String_Node_Str";
    log.debug(message);
    throw new PermissionDenied(message);
  }
  HarvestDefinition preHD=null;
  if (hd instanceof FullHarvest) {
    preHD=((FullHarvest)hd).getPreviousHarvestDefinition();
  }
  Connection c=HarvestDBConnection.get();
  PreparedStatement s=null;
  try {
    c.setAutoCommit(false);
    s=c.prepareStatement("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
    DBUtils.setName(s,1,hd,Constants.MAX_NAME_SIZE);
    DBUtils.setComments(s,2,hd,Constants.MAX_COMMENT_SIZE);
    s.setInt(3,hd.getNumEvents());
    s.setTimestamp(4,new Timestamp(hd.getSubmissionDate().getTime()));
    s.setBoolean(5,hd.getActive());
    long nextEdition=hd.getEdition() + 1;
    s.setLong(6,nextEdition);
    s.setLong(7,hd.getOid());
    s.setLong(8,hd.getEdition());
    int rows=s.executeUpdate();
    if (rows == 0) {
      String message="String_Node_Str" + hd + "String_Node_Str"+ hd.getEdition()+ "String_Node_Str";
      log.debug(message);
      throw new PermissionDenied(message);
    }
    s.close();
    if (hd instanceof FullHarvest) {
      FullHarvest fh=(FullHarvest)hd;
      s=c.prepareStatement("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
      if (preHD != null) {
        s.setLong(1,preHD.getOid());
      }
 else {
        s.setNull(1,Types.BIGINT);
      }
      s.setLong(2,fh.getMaxCountObjects());
      s.setLong(3,fh.getMaxBytes());
      s.setLong(4,fh.getMaxJobRunningTime());
      s.setBoolean(5,fh.getIndexReady());
      s.setLong(6,fh.getOid());
      rows=s.executeUpdate();
      log.debug(rows + "String_Node_Str");
    }
 else     if (hd instanceof PartialHarvest) {
      PartialHarvest ph=(PartialHarvest)hd;
      s=c.prepareStatement("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
      s.setString(1,ph.getSchedule().getName());
      DBUtils.setDateMaybeNull(s,2,ph.getNextDate());
      s.setLong(3,ph.getOid());
      rows=s.executeUpdate();
      log.debug(rows + "String_Node_Str");
      s.close();
      createHarvestConfigsEntries(c,ph,ph.getOid());
    }
 else {
      String message="String_Node_Str" + hd + "String_Node_Str"+ hd.getClass();
      log.warn(message);
      throw new ArgumentNotValid(message);
    }
    c.commit();
    hd.setEdition(nextEdition);
  }
 catch (  SQLException e) {
    throw new IOFailure("String_Node_Str" + hd + "String_Node_Str"+ ExceptionUtils.getSQLExceptionCause(e),e);
  }
 finally {
    DBUtils.rollbackIfNeeded(c,"String_Node_Str",hd);
    HarvestDBConnection.release(c);
  }
}