Program: 132500
Project: 132500
Buggy source:
/** 
 * Starts the BabuDB database (with replication). Hidden main constructor.
 * @param baseDir directory in which the database snapshots are stored
 * @param dbLogDir directory in which the database append logs are stored (can be same as baseDir)
 * @param numThreads number of worker threads to use
 * @param maxLogfileSize a checkpoint is generated if  maxLogfileSize is exceeded
 * @param checkInterval interval between two checks in seconds, 0 disables auto checkpointing
 * @param syncMode the synchronization mode to use for the logfile
 * @param pseudoSyncWait if value > 0 then requests are immediateley aknowledged and synced to disk everypseudoSyncWait ms.
 * @param maxQ if > 0, the queue for each worker is limited to maxQ
 * @param master host, from which replicas are received
 * @param slaves hosts, where the replicas should be send to
 * @param isMaster <p>if true, the BabuDB will be started as Master, if false it will be started as slaves. But if the <code>slaves</code> or <code>master</code> are set to null it will be started without replication.</p>
 * @param port where the application listens at. (use 0 for default configuration)
 * @param ssl if set SSL will be used while replication.
 * @param repMode repMode == 0: asynchronous replication mode</br>repMode == slaves.size(): synchronous replication mode</br> repMode > 0 && repMode < slaves.size(): N -sync replication mode with N = repMode
 * @param qLimit if > 0, the queue for the replication-requests is limited to qLimit
 * @throws BabuDBException
 */
BabuDBImpl(String baseDir,String dbLogDir,int numThreads,long maxLogfileSize,int checkInterval,SyncMode syncMode,int pseudoSyncWait,int maxQ,InetSocketAddress master,List<InetSocketAddress> slaves,int port,SSLOptions ssl,boolean isMaster,int repMode,int qLimit) throws BabuDBException {
  overlaySwitchLock=new ReentrantReadWriteLock();
  if (!baseDir.endsWith(File.separator)) {
    baseDir=baseDir + File.separatorChar;
  }
  Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + baseDir);
  if (!dbLogDir.endsWith(File.separator)) {
    dbLogDir=dbLogDir + File.separatorChar;
  }
  Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + dbLogDir);
  this.configuration=new BabuDBConfiguration(baseDir,dbLogDir,maxQ,numThreads,syncMode,maxLogfileSize,checkInterval,pseudoSyncWait);
  if (master != null && slaves != null) {
    this.configuration.replication_master=master;
    this.configuration.replication_slaves=slaves;
    try {
      if (isMaster) {
        replicationFacade=new Replication(slaves,ssl,port,this,repMode,qLimit,overlaySwitchLock.readLock(),Replication.DEFAULT_NO_TRIES);
      }
 else {
        replicationFacade=new Replication(master,ssl,port,this,repMode,qLimit,overlaySwitchLock.readLock(),Replication.DEFAULT_NO_TRIES);
      }
    }
 catch (    Exception e) {
      throw new BabuDBException(ErrorCode.REPLICATION_FAILURE,"String_Node_Str" + e.getMessage(),e.getCause());
    }
  }
 else {
    replicationFacade=null;
  }
  dbNames=new HashMap<String,LSMDatabase>();
  databases=new HashMap<Integer,LSMDatabase>();
  nextDbId=1;
  compInstances=new HashMap<String,ByteRangeComparator>();
  compInstances.put(DefaultByteRangeComparator.class.getName(),new DefaultByteRangeComparator());
  loadDBs();
  Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str");
  LSN nextLSN=replayLogs();
  Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str");
  try {
    logger=new DiskLogger(dbLogDir,nextLSN.getViewId(),nextLSN.getSequenceNo(),syncMode,pseudoSyncWait,maxQ * numThreads);
    logger.start();
  }
 catch (  IOException ex) {
    throw new BabuDBException(ErrorCode.IO_ERROR,"String_Node_Str",ex);
  }
  dbModificationLock=new Object();
  checkpointLock=new Object();
  worker=new LSMDBWorker[numThreads];
  for (int i=0; i < numThreads; i++) {
    worker[i]=new LSMDBWorker(logger,i,overlaySwitchLock,(pseudoSyncWait > 0),maxQ,replicationFacade);
    worker[i].start();
  }
  if (checkInterval > 0) {
    dbCheckptr=new Checkpointer(this,logger,checkInterval,maxLogfileSize);
    dbCheckptr.start();
  }
 else {
    dbCheckptr=null;
  }
  Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str" + BABUDB_VERSION + "String_Node_Str");
}

Fixed version (ground truth):
/** 
 * DUMMY - constructor for testing only!
 */
public BabuDBImpl(){
  replicationFacade=null;
  dbNames=null;
  dbModificationLock=null;
  databases=null;
  configuration=null;
  compInstances=null;
  checkpointLock=null;
}