Program: 132394
Project: 132394
Buggy source:
/** 
 * <p> Needed for the initial load process of the babuDB, done by the replication. </p>
 * @throws BabuDBException
 * @return the next LSN.
 */
public LSN restart() throws BabuDBException {
  if (!this.stopped)   throw new BabuDBException(ErrorCode.IO_ERROR,"String_Node_Str");
  databaseManager.reset();
  dbCheckptr=new CheckpointerImpl(this);
  LSN dbLsn=null;
  LSN zero=new LSN(0,0L);
  for (  Database dbRaw : databaseManager.getDatabaseList()) {
    DatabaseImpl db=(DatabaseImpl)dbRaw;
    LSN onDisk=db.getLSMDB().getOndiskLSN();
    if (dbLsn == null && !onDisk.equals(zero))     dbLsn=onDisk;
 else     if (dbLsn != null) {
      if (!onDisk.equals(zero) && !dbLsn.equals(onDisk))       throw new RuntimeException("String_Node_Str" + dbLsn.toString() + "String_Node_Str"+ db.getLSMDB().getOndiskLSN().toString());
    }
  }
  if (dbLsn == null) {
    dbLsn=new LSN(0,0);
  }
 else {
    dbLsn=new LSN(dbLsn.getViewId(),dbLsn.getSequenceNo() + 1);
  }
  Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str");
  LSN nextLSN=replayLogs(dbLsn);
  if (dbLsn.compareTo(nextLSN) > 0) {
    nextLSN=dbLsn;
  }
  Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str" + nextLSN);
  try {
    logger=new DiskLogger(configuration.getDbLogDir(),nextLSN.getViewId(),nextLSN.getSequenceNo() + 1L,configuration.getSyncMode(),configuration.getPseudoSyncWait(),configuration.getMaxQueueLength() * configuration.getNumThreads());
    logger.start();
  }
 catch (  IOException ex) {
    throw new BabuDBException(ErrorCode.IO_ERROR,"String_Node_Str",ex);
  }
  worker=new LSMDBWorker[configuration.getNumThreads()];
  for (int i=0; i < configuration.getNumThreads(); i++) {
    worker[i]=new LSMDBWorker(logger,i,(configuration.getPseudoSyncWait() > 0),configuration.getMaxQueueLength(),replicationManager);
    worker[i].start();
  }
  dbCheckptr.init(logger,configuration.getCheckInterval(),configuration.getMaxLogfileSize());
  dbCheckptr.start();
  Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str" + "String_Node_Str" + BABUDB_VERSION + "String_Node_Str");
  this.stopped=false;
  return new LSN(nextLSN.getViewId(),nextLSN.getSequenceNo());
}

Fixed version (ground truth):
/** 
 * <p> Needed for the initial load process of the babuDB, done by the replication. </p>
 * @throws BabuDBException
 * @return the next LSN.
 */
public LSN restart() throws BabuDBException {
  if (!this.stopped)   throw new BabuDBException(ErrorCode.IO_ERROR,"String_Node_Str");
  databaseManager.reset();
  dbCheckptr=new CheckpointerImpl(this);
  LSN dbLsn=null;
  LSN zero=new LSN(0,0L);
  for (  Database dbRaw : databaseManager.getDatabaseList()) {
    DatabaseImpl db=(DatabaseImpl)dbRaw;
    LSN onDisk=db.getLSMDB().getOndiskLSN();
    if (dbLsn == null && !onDisk.equals(zero))     dbLsn=onDisk;
 else     if (dbLsn != null) {
      if (!onDisk.equals(zero) && !dbLsn.equals(onDisk))       throw new RuntimeException("String_Node_Str" + dbLsn.toString() + "String_Node_Str"+ db.getLSMDB().getOndiskLSN().toString());
    }
  }
  if (dbLsn == null) {
    dbLsn=new LSN(0,0);
  }
 else {
    dbLsn=new LSN(dbLsn.getViewId(),dbLsn.getSequenceNo() + 1);
  }
  Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str");
  LSN nextLSN=replayLogs(dbLsn);
  if (dbLsn.compareTo(nextLSN) > 0) {
    nextLSN=dbLsn;
  }
  Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str" + nextLSN);
  try {
    logger=new DiskLogger(configuration.getDbLogDir(),nextLSN.getViewId(),nextLSN.getSequenceNo(),configuration.getSyncMode(),configuration.getPseudoSyncWait(),configuration.getMaxQueueLength() * configuration.getNumThreads());
    logger.start();
  }
 catch (  IOException ex) {
    throw new BabuDBException(ErrorCode.IO_ERROR,"String_Node_Str",ex);
  }
  worker=new LSMDBWorker[configuration.getNumThreads()];
  for (int i=0; i < configuration.getNumThreads(); i++) {
    worker[i]=new LSMDBWorker(logger,i,(configuration.getPseudoSyncWait() > 0),configuration.getMaxQueueLength(),replicationManager);
    worker[i].start();
  }
  dbCheckptr.init(logger,configuration.getCheckInterval(),configuration.getMaxLogfileSize());
  dbCheckptr.start();
  Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str" + "String_Node_Str" + BABUDB_VERSION + "String_Node_Str");
  this.stopped=false;
  return new LSN(nextLSN.getViewId(),nextLSN.getSequenceNo() - 1L);
}