Program: 89698
Project: 89698
Buggy source:
/** 
 * Read the stored harvest definition for the given ID.
 * @see HarvestDefinitionDAO#read(Long)
 * @param harvestDefinitionID An ID number for a harvest definition
 * @return A harvest definition that has been read from persistent storage.
 * @throws UnknownID if no entry with that ID exists in the database
 * @throws IOFailure If DB-failure occurs?
 */
private HarvestDefinition read(Connection c,Long harvestDefinitionID) throws UnknownID, IOFailure {
  if (!exists(c,harvestDefinitionID)) {
    String message="String_Node_Str" + harvestDefinitionID;
    log.debug(message);
    throw new UnknownID(message);
  }
  log.debug("String_Node_Str" + harvestDefinitionID);
  PreparedStatement s=null;
  try {
    s=c.prepareStatement("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
    s.setLong(1,harvestDefinitionID);
    ResultSet res=s.executeQuery();
    if (res.next()) {
      log.debug("String_Node_Str" + harvestDefinitionID);
      final String name=res.getString(1);
      final String comments=res.getString(2);
      final int numEvents=res.getInt(3);
      final Date submissionDate=new Date(res.getTimestamp(4).getTime());
      final long maxObjects=res.getLong(6);
      final long maxBytes=res.getLong(7);
      final long maxJobRunningtime=res.getLong(8);
      FullHarvest fh;
      final long prevhd=res.getLong(5);
      if (!res.wasNull()) {
        fh=new FullHarvest(name,comments,prevhd,maxObjects,maxBytes,maxJobRunningtime);
      }
 else {
        fh=new FullHarvest(name,comments,null,maxObjects,maxBytes,maxJobRunningtime);
      }
      fh.setSubmissionDate(submissionDate);
      fh.setNumEvents(numEvents);
      fh.setActive(res.getBoolean(9));
      fh.setOid(harvestDefinitionID);
      fh.setEdition(res.getLong(10));
      log.debug("String_Node_Str" + harvestDefinitionID);
      return fh;
    }
    s.close();
    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"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
    s.setLong(1,harvestDefinitionID);
    res=s.executeQuery();
    boolean foundPartialHarvest=res.next();
    if (foundPartialHarvest) {
      log.debug("String_Node_Str" + harvestDefinitionID);
      final String name=res.getString(1);
      final String comments=res.getString(2);
      final int numEvents=res.getInt(3);
      final Date submissionDate=new Date(res.getTimestamp(4).getTime());
      final boolean active=res.getBoolean(5);
      final long edition=res.getLong(6);
      final String scheduleName=res.getString(7);
      final Date nextDate=DBUtils.getDateMaybeNull(res,8);
      s.close();
      final DomainDAO domainDao=DomainDAO.getInstance();
      /** 
 * Helper class that contain (domainName, configName) pairs.
 */
class DomainConfigPair {
        /** 
 * The domain name. 
 */
        final String domainName;
        /** 
 * The config name. 
 */
        final String configName;
        /** 
 * Constructor for the DomainConfigPair class.
 * @param domainName A given domain name
 * @param configName A name for a specific configuration
 */
        public DomainConfigPair(        String domainName,        String configName){
          this.domainName=domainName;
          this.configName=configName;
        }
      }
      List<DomainConfigPair> configs=new ArrayList<DomainConfigPair>();
      s=c.prepareStatement("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
      s.setLong(1,harvestDefinitionID);
      res=s.executeQuery();
      while (res.next()) {
        configs.add(new DomainConfigPair(res.getString(1),res.getString(2)));
      }
      s.close();
      List<DomainConfiguration> configurations=new ArrayList<DomainConfiguration>();
      for (      DomainConfigPair domainConfig : configs) {
        Domain d=domainDao.read(domainConfig.domainName);
        configurations.add(d.getConfiguration(domainConfig.configName));
      }
      Schedule schedule=ScheduleDAO.getInstance().read(scheduleName);
      PartialHarvest ph=new PartialHarvest(configurations,schedule,name,comments);
      ph.setNumEvents(numEvents);
      ph.setSubmissionDate(submissionDate);
      ph.setActive(active);
      ph.setEdition(edition);
      ph.setNextDate(nextDate);
      ph.setOid(harvestDefinitionID);
      return ph;
    }
 else {
      throw new IllegalState("String_Node_Str" + "String_Node_Str" + harvestDefinitionID);
    }
  }
 catch (  SQLException e) {
    throw new IOFailure("String_Node_Str" + harvestDefinitionID + "String_Node_Str"+ ExceptionUtils.getSQLExceptionCause(e),e);
  }
}

Fixed version (ground truth):
/** 
 * Read the stored harvest definition for the given ID.
 * @see HarvestDefinitionDAO#read(Long)
 * @param c The used database connection
 * @param harvestDefinitionID An ID number for a harvest definition
 * @return A harvest definition that has been read from persistent storage.
 * @throws UnknownID if no entry with that ID exists in the database
 * @throws IOFailure If DB-failure occurs?
 */
private HarvestDefinition read(Connection c,Long harvestDefinitionID) throws UnknownID, IOFailure {
  if (!exists(c,harvestDefinitionID)) {
    String message="String_Node_Str" + harvestDefinitionID;
    log.debug(message);
    throw new UnknownID(message);
  }
  log.debug("String_Node_Str" + harvestDefinitionID);
  PreparedStatement s=null;
  try {
    s=c.prepareStatement("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
    s.setLong(1,harvestDefinitionID);
    ResultSet res=s.executeQuery();
    if (res.next()) {
      log.debug("String_Node_Str" + harvestDefinitionID);
      final String name=res.getString(1);
      final String comments=res.getString(2);
      final int numEvents=res.getInt(3);
      final Date submissionDate=new Date(res.getTimestamp(4).getTime());
      final long maxObjects=res.getLong(6);
      final long maxBytes=res.getLong(7);
      final long maxJobRunningtime=res.getLong(8);
      FullHarvest fh;
      final long prevhd=res.getLong(5);
      if (!res.wasNull()) {
        fh=new FullHarvest(name,comments,prevhd,maxObjects,maxBytes,maxJobRunningtime);
      }
 else {
        fh=new FullHarvest(name,comments,null,maxObjects,maxBytes,maxJobRunningtime);
      }
      fh.setSubmissionDate(submissionDate);
      fh.setNumEvents(numEvents);
      fh.setActive(res.getBoolean(9));
      fh.setOid(harvestDefinitionID);
      fh.setEdition(res.getLong(10));
      log.debug("String_Node_Str" + harvestDefinitionID);
      return fh;
    }
    s.close();
    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"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
    s.setLong(1,harvestDefinitionID);
    res=s.executeQuery();
    boolean foundPartialHarvest=res.next();
    if (foundPartialHarvest) {
      log.debug("String_Node_Str" + harvestDefinitionID);
      final String name=res.getString(1);
      final String comments=res.getString(2);
      final int numEvents=res.getInt(3);
      final Date submissionDate=new Date(res.getTimestamp(4).getTime());
      final boolean active=res.getBoolean(5);
      final long edition=res.getLong(6);
      final String scheduleName=res.getString(7);
      final Date nextDate=DBUtils.getDateMaybeNull(res,8);
      s.close();
      final DomainDAO domainDao=DomainDAO.getInstance();
      /** 
 * Helper class that contain (domainName, configName) pairs.
 */
class DomainConfigPair {
        /** 
 * The domain name. 
 */
        final String domainName;
        /** 
 * The config name. 
 */
        final String configName;
        /** 
 * Constructor for the DomainConfigPair class.
 * @param domainName A given domain name
 * @param configName A name for a specific configuration
 */
        public DomainConfigPair(        String domainName,        String configName){
          this.domainName=domainName;
          this.configName=configName;
        }
      }
      List<DomainConfigPair> configs=new ArrayList<DomainConfigPair>();
      s=c.prepareStatement("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
      s.setLong(1,harvestDefinitionID);
      res=s.executeQuery();
      while (res.next()) {
        configs.add(new DomainConfigPair(res.getString(1),res.getString(2)));
      }
      s.close();
      List<DomainConfiguration> configurations=new ArrayList<DomainConfiguration>();
      for (      DomainConfigPair domainConfig : configs) {
        Domain d=domainDao.read(domainConfig.domainName);
        configurations.add(d.getConfiguration(domainConfig.configName));
      }
      Schedule schedule=ScheduleDAO.getInstance().read(scheduleName);
      PartialHarvest ph=new PartialHarvest(configurations,schedule,name,comments);
      ph.setNumEvents(numEvents);
      ph.setSubmissionDate(submissionDate);
      ph.setActive(active);
      ph.setEdition(edition);
      ph.setNextDate(nextDate);
      ph.setOid(harvestDefinitionID);
      return ph;
    }
 else {
      throw new IllegalState("String_Node_Str" + "String_Node_Str" + harvestDefinitionID);
    }
  }
 catch (  SQLException e) {
    throw new IOFailure("String_Node_Str" + harvestDefinitionID + "String_Node_Str"+ ExceptionUtils.getSQLExceptionCause(e),e);
  }
}