Program: 93060
Project: 93060
Buggy source:
/** 
 * Loads into the PersonList the entire person table from the MPI, along with any joining person relation data. Uses multiple threads to do this, to minimize loading time.
 */
public void load(){
  int personCount=0;
  try {
    Connection conn=Sql.connect();
    String sql="String_Node_Str";
    ResultSet rs=Sql.query(conn,sql);
    List<Integer> personIds=new ArrayList<Integer>();
    rs.next();
    personCount=rs.getInt("String_Node_Str");
    Sql.close(rs);
    Sql.close(conn);
  }
 catch (  SQLException ex) {
    Logger.getLogger(PersonList.class.getName()).log(Level.SEVERE,null,ex);
  }
  String queryLimitString=Mediator.getProperty("String_Node_Str");
  if (queryLimitString != null) {
    int limit=Integer.parseInt(queryLimitString);
    if (limit < personCount) {
      personCount=limit;
    }
  }
  if (personCount > 0) {
    int threadCount=Mpi.getMaxThreadCount();
    if (threadCount > personCount) {
      threadCount=personCount;
    }
    int countPerThread=(personCount + threadCount - 1) / threadCount;
    int[] cutoffs=null;
    try {
      Connection conn=Sql.connect();
      String sql="String_Node_Str";
      ResultSet rs=Sql.query(conn,sql);
      cutoffs=new int[threadCount + 1];
      cutoffs[0]=0;
      int row=0;
      int nextCutoff=countPerThread;
      int iCutoff=1;
      while (rs.next() && row++ < personCount) {
        if (row == nextCutoff || row == personCount) {
          cutoffs[iCutoff++]=rs.getInt("String_Node_Str");
          nextCutoff+=countPerThread;
        }
      }
      Sql.close(rs);
      Sql.close(conn);
    }
 catch (    SQLException ex) {
      Logger.getLogger(PersonList.class.getName()).log(Level.SEVERE,null,ex);
    }
    long startTime=System.currentTimeMillis();
    Thread[] threadArray=new Thread[threadCount];
    LoadPersonThread[] loadPersonThreadArray=new LoadPersonThread[threadCount];
    for (int i=0; i < threadCount; i++) {
      int minPersonId=cutoffs[i] + 1;
      int maxPersonId=cutoffs[i + 1];
      LoadPersonThread lpt=new LoadPersonThread(i,minPersonId,maxPersonId);
      Thread t=new Thread(lpt);
      loadPersonThreadArray[i]=lpt;
      threadArray[i]=t;
      t.start();
    }
    for (int i=0; i < threadCount; i++) {
      Thread t=threadArray[i];
      try {
        t.join();
      }
 catch (      InterruptedException ex) {
        Logger.getLogger(PersonList.class.getName()).log(Level.SEVERE,"String_Node_Str",ex);
      }
      LoadPersonThread lpt=loadPersonThreadArray[i];
      loadPersonThreadArray[i]=null;
      List<PersonMatch> personMatchList=lpt.getPersonMatchList();
      for (      PersonMatch pm : personMatchList) {
        add(pm);
      }
      long finishTime=lpt.getFinishTime();
      double timeInterval=(finishTime - startTime);
      Mediator.getLogger(PersonList.class.getName()).log(Level.FINE,"String_Node_Str",new Object[]{i,personMatchList.size(),timeInterval});
    }
    double timeInterval=(System.currentTimeMillis() - startTime);
    Mediator.getLogger(PersonList.class.getName()).log(Level.FINE,"String_Node_Str",new Object[]{personList.size(),timeInterval});
  }
}

Fixed version (ground truth):
/** 
 * Loads into the PersonList the entire person table from the MPI, along with any joining person relation data. Uses multiple threads to do this, to minimize loading time.
 */
public void load(){
  int personCount=0;
  try {
    Connection conn=Sql.connect();
    String sql="String_Node_Str";
    ResultSet rs=Sql.query(conn,sql);
    List<Integer> personIds=new ArrayList<Integer>();
    rs.next();
    personCount=rs.getInt("String_Node_Str");
    Sql.close(rs);
    Sql.close(conn);
  }
 catch (  SQLException ex) {
    Logger.getLogger(PersonList.class.getName()).log(Level.SEVERE,null,ex);
  }
  String queryLimitString=Mediator.getProperty("String_Node_Str");
  if (queryLimitString != null) {
    int limit=Integer.parseInt(queryLimitString);
    if (limit < personCount) {
      personCount=limit;
    }
  }
  if (personCount > 0) {
    int threadCount=Mpi.getMaxThreadCount();
    if (threadCount > personCount) {
      threadCount=personCount;
    }
    int countPerThread=(personCount + threadCount - 1) / threadCount;
    int[] cutoffs=null;
    try {
      Connection conn=Sql.connect();
      String sql="String_Node_Str";
      ResultSet rs=Sql.query(conn,sql);
      cutoffs=new int[threadCount + 1];
      cutoffs[0]=0;
      int row=0;
      int nextCutoff=countPerThread;
      int iCutoff=1;
      while (rs.next() && row++ < personCount) {
        if (row == nextCutoff || row == personCount) {
          cutoffs[iCutoff++]=rs.getInt("String_Node_Str");
          nextCutoff+=countPerThread;
        }
      }
      Sql.close(rs);
      Sql.close(conn);
    }
 catch (    SQLException ex) {
      Logger.getLogger(PersonList.class.getName()).log(Level.SEVERE,null,ex);
    }
    long startTime=System.currentTimeMillis();
    Thread[] threadArray=new Thread[threadCount];
    LoadPersonThread[] loadPersonThreadArray=new LoadPersonThread[threadCount];
    for (int i=0; i < threadCount; i++) {
      int minPersonId=cutoffs[i] + 1;
      int maxPersonId=cutoffs[i + 1];
      LoadPersonThread lpt=new LoadPersonThread(i,minPersonId,maxPersonId);
      Thread t=new Thread(lpt);
      loadPersonThreadArray[i]=lpt;
      threadArray[i]=t;
      t.start();
      waitAMoment();
    }
    for (int i=0; i < threadCount; i++) {
      Thread t=threadArray[i];
      try {
        t.join();
      }
 catch (      InterruptedException ex) {
        Logger.getLogger(PersonList.class.getName()).log(Level.SEVERE,"String_Node_Str",ex);
      }
      LoadPersonThread lpt=loadPersonThreadArray[i];
      loadPersonThreadArray[i]=null;
      List<PersonMatch> personMatchList=lpt.getPersonMatchList();
      for (      PersonMatch pm : personMatchList) {
        add(pm);
      }
    }
    double timeInterval=(System.currentTimeMillis() - startTime);
    Mediator.getLogger(PersonList.class.getName()).log(Level.FINE,"String_Node_Str",new Object[]{personList.size(),timeInterval});
  }
}