Program: 132374
Project: 132374
Buggy source:
/** 
 * Starts the BabuDB database. If conf is instance of MasterConfig it comes with replication in master-mode. If conf is instance of SlaveConfig it comes with replication in slave-mode.
 * @param conf
 * @throws BabuDBException
 */
BabuDB(BabuDBConfig conf) throws BabuDBException {
  Logging.start(conf.getDebugLevel());
  Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + conf.getBaseDir());
  Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + conf.getDbLogDir());
  this.configuration=conf;
  this.databaseManager=new DatabaseManagerImpl(this);
  this.dbConfigFile=new DBConfig(this);
  this.snapshotManager=new SnapshotManagerImpl(this);
  this.dbCheckptr=new CheckpointerImpl(this);
  if (dbConfigFile.isConversionRequired()) {
    Logging.logMessage(Logging.LEVEL_WARN,Category.db,this,"String_Node_Str");
    AutoConverter.initiateConversion(dbConfigFile.getDBFormatVersion(),conf);
  }
  try {
    if (conf instanceof ReplicationConfig)     DirectFileIO.replayBackupFiles((ReplicationConfig)conf);
  }
 catch (  IOException io) {
    Logging.logMessage(Logging.LEVEL_ERROR,this,"String_Node_Str" + "String_Node_Str",io.getMessage());
  }
  LSN dbLsn=null;
  for (  Database db : databaseManager.getDatabaseList()) {
    if (dbLsn == null)     dbLsn=((DatabaseImpl)db).getLSMDB().getOndiskLSN();
 else {
      LSN onDiskLSN=((DatabaseImpl)db).getLSMDB().getOndiskLSN();
      if (!LSMDatabase.NO_DB_LSN.equals(onDiskLSN) && !dbLsn.equals(onDiskLSN))       throw new RuntimeException("String_Node_Str");
    }
  }
  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);
  LSN lastLSN=new LSN(nextLSN.getViewId(),nextLSN.getSequenceNo() - 1);
  try {
    if (conf instanceof ReplicationConfig)     this.replicationManager=new ReplicationManagerImpl(this,lastLSN);
 else     this.replicationManager=null;
  }
 catch (  Exception e) {
    throw new BabuDBException(ErrorCode.REPLICATION_FAILURE,e.getMessage());
  }
  try {
    this.logger=new DiskLogger(conf.getDbLogDir(),nextLSN.getViewId(),nextLSN.getSequenceNo(),conf.getSyncMode(),conf.getPseudoSyncWait(),conf.getMaxQueueLength() * conf.getNumThreads(),replicationManager);
    this.logger.start();
  }
 catch (  IOException ex) {
    throw new BabuDBException(ErrorCode.IO_ERROR,"String_Node_Str",ex);
  }
  if (conf.getNumThreads() > 0) {
    worker=new LSMDBWorker[conf.getNumThreads()];
    for (int i=0; i < conf.getNumThreads(); i++) {
      worker[i]=new LSMDBWorker(logger,i,(conf.getPseudoSyncWait() > 0),conf.getMaxQueueLength());
      worker[i].start();
    }
  }
 else {
    assert(conf.getNumThreads() == 0);
    worker=null;
  }
  if (dbConfigFile.isConversionRequired())   AutoConverter.completeConversion(this);
  snapshotManager.init();
  dbCheckptr.init(logger,conf.getCheckInterval(),conf.getMaxLogfileSize());
  dbCheckptr.start();
  this.stopped=new AtomicBoolean(false);
  if (this.replicationManager != null)   this.replicationManager.initialize();
  Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str" + "String_Node_Str" + BABUDB_VERSION + "String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Starts the BabuDB database. If conf is instance of MasterConfig it comes with replication in master-mode. If conf is instance of SlaveConfig it comes with replication in slave-mode.
 * @param conf
 * @throws BabuDBException
 */
BabuDB(BabuDBConfig conf) throws BabuDBException {
  Logging.start(conf.getDebugLevel());
  Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + conf.getBaseDir());
  Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + conf.getDbLogDir());
  this.configuration=conf;
  this.databaseManager=new DatabaseManagerImpl(this);
  this.dbConfigFile=new DBConfig(this);
  this.snapshotManager=new SnapshotManagerImpl(this);
  this.dbCheckptr=new CheckpointerImpl(this);
  if (dbConfigFile.isConversionRequired()) {
    Logging.logMessage(Logging.LEVEL_WARN,Category.db,this,"String_Node_Str");
    AutoConverter.initiateConversion(dbConfigFile.getDBFormatVersion(),conf);
  }
  snapshotManager.init();
  try {
    if (conf instanceof ReplicationConfig)     DirectFileIO.replayBackupFiles((ReplicationConfig)conf);
  }
 catch (  IOException io) {
    Logging.logMessage(Logging.LEVEL_ERROR,this,"String_Node_Str" + "String_Node_Str",io.getMessage());
  }
  LSN dbLsn=null;
  for (  Database db : databaseManager.getDatabaseList()) {
    if (dbLsn == null)     dbLsn=((DatabaseImpl)db).getLSMDB().getOndiskLSN();
 else {
      LSN onDiskLSN=((DatabaseImpl)db).getLSMDB().getOndiskLSN();
      if (!LSMDatabase.NO_DB_LSN.equals(onDiskLSN) && !dbLsn.equals(onDiskLSN))       throw new RuntimeException("String_Node_Str");
    }
  }
  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);
  LSN lastLSN=new LSN(nextLSN.getViewId(),nextLSN.getSequenceNo() - 1);
  try {
    if (conf instanceof ReplicationConfig)     this.replicationManager=new ReplicationManagerImpl(this,lastLSN);
 else     this.replicationManager=null;
  }
 catch (  Exception e) {
    throw new BabuDBException(ErrorCode.REPLICATION_FAILURE,e.getMessage());
  }
  try {
    this.logger=new DiskLogger(conf.getDbLogDir(),nextLSN.getViewId(),nextLSN.getSequenceNo(),conf.getSyncMode(),conf.getPseudoSyncWait(),conf.getMaxQueueLength() * conf.getNumThreads(),replicationManager);
    this.logger.start();
  }
 catch (  IOException ex) {
    throw new BabuDBException(ErrorCode.IO_ERROR,"String_Node_Str",ex);
  }
  if (conf.getNumThreads() > 0) {
    worker=new LSMDBWorker[conf.getNumThreads()];
    for (int i=0; i < conf.getNumThreads(); i++) {
      worker[i]=new LSMDBWorker(logger,i,(conf.getPseudoSyncWait() > 0),conf.getMaxQueueLength());
      worker[i].start();
    }
  }
 else {
    assert(conf.getNumThreads() == 0);
    worker=null;
  }
  if (dbConfigFile.isConversionRequired())   AutoConverter.completeConversion(this);
  dbCheckptr.init(logger,conf.getCheckInterval(),conf.getMaxLogfileSize());
  dbCheckptr.start();
  this.stopped=new AtomicBoolean(false);
  if (this.replicationManager != null)   this.replicationManager.initialize();
  Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str" + "String_Node_Str" + BABUDB_VERSION + "String_Node_Str");
}