nus-yam/ex-repair huggingface dataset:
Program: 132285
Project: 132285
Buggy source:
/** 
 * Main loop.
 */
public void run(){
  List<LogEntry> tmpE=new ArrayList<LogEntry>(MAX_ENTRIES_PER_BLOCK);
  Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str");
  notifyStarted();
  while (!quit) {
    try {
synchronized (this) {
        if (entries.isEmpty()) {
          wait();
        }
        if (quit) {
          break;
        }
 else {
          LogEntry tmp=null;
          while (tmpE.size() < MAX_ENTRIES_PER_BLOCK - 1 && (tmp=entries.poll()) != null) {
            tmpE.add(tmp);
          }
          notifyAll();
          lock();
        }
      }
      processLogEntries(tmpE);
    }
 catch (    IOException ex) {
      Logging.logError(Logging.LEVEL_ERROR,this,ex);
      for (      LogEntry le : tmpE) {
        le.free();
        le.getListener().failed(ex);
      }
      tmpE.clear();
    }
catch (    InterruptedException ex) {
      if (!quit) {
        try {
          cleanUp();
        }
 catch (        IOException e) {
          Logging.logError(Logging.LEVEL_ERROR,this,e);
        }
        notifyCrashed(ex);
        return;
      }
    }
 finally {
      if (hasLock())       unlock();
    }
  }
  try {
    if (graceful) {
      try {
        lock();
        processLogEntries(entries);
      }
  finally {
        unlock();
      }
    }
    cleanUp();
    Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str");
    notifyStopped();
  }
 catch (  Exception e) {
    notifyCrashed(e);
  }
}

Fixed version (ground truth):
/** 
 * Main loop.
 */
public void run(){
  List<LogEntry> tmpE=new ArrayList<LogEntry>(MAX_ENTRIES_PER_BLOCK);
  Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str");
  notifyStarted();
  while (!quit) {
    try {
synchronized (this) {
        if (!quit && entries.isEmpty()) {
          wait();
        }
        if (quit) {
          break;
        }
 else {
          LogEntry tmp=null;
          while (tmpE.size() < MAX_ENTRIES_PER_BLOCK - 1 && (tmp=entries.poll()) != null) {
            tmpE.add(tmp);
          }
          notifyAll();
          lock();
        }
      }
      processLogEntries(tmpE);
    }
 catch (    IOException ex) {
      Logging.logError(Logging.LEVEL_ERROR,this,ex);
      for (      LogEntry le : tmpE) {
        le.free();
        le.getListener().failed(ex);
      }
      tmpE.clear();
    }
catch (    InterruptedException ex) {
      if (!quit) {
        try {
          cleanUp();
        }
 catch (        IOException e) {
          Logging.logError(Logging.LEVEL_ERROR,this,e);
        }
        notifyCrashed(ex);
        return;
      }
    }
 finally {
      if (hasLock())       unlock();
    }
  }
  try {
    if (graceful) {
      try {
        lock();
        processLogEntries(entries);
      }
  finally {
        unlock();
      }
    }
    cleanUp();
    Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str");
    notifyStopped();
  }
 catch (  Exception e) {
    notifyCrashed(e);
  }
}
Program: 132286
Project: 132286
Buggy source:
/** 
 * @return a map of all available databases identified by their names.
 * @throws BabuDBException 
 */
public Map<String,DatabaseInternal> getDatabases(){
  return getDBMan().getDatabasesInternal();
}

Fixed version (ground truth):
/** 
 * @return a map of all available databases identified by their names.
 * @throws BabuDBException 
 */
public Map<String,DatabaseProxy> getDatabases(){
  return dbMan.getDatabasesInternalNonblocking();
}
Program: 132287
Project: 132287
Buggy source:
/** 
 * @return a collection of all {@link DBFileMetaData} objects for the latestsnapshot available for every database, after cutting them into chunks of chunkSize at maximum.
 */
public Collection<DBFileMetaData> getAllSnapshotFiles(){
  List<DBFileMetaData> result=new Vector<DBFileMetaData>();
  for (  DatabaseInternal db : getDBMan().getDatabaseList()) {
    result.addAll(db.getLSMDB().getLastestSnapshotFiles());
  }
  return result;
}

Fixed version (ground truth):
/** 
 * @return a collection of all {@link DBFileMetaData} objects for the latestsnapshot available for every database, after cutting them into chunks of chunkSize at maximum.
 */
public Collection<DBFileMetaData> getAllSnapshotFiles(){
  List<DBFileMetaData> result=new Vector<DBFileMetaData>();
  for (  DatabaseProxy db : dbMan.getDatabaseListNonblocking()) {
    result.addAll(db.getLSMDB().getLastestSnapshotFiles());
  }
  return result;
}
Program: 132288
Project: 132288
Buggy source:
/** 
 * @param dbId
 * @return an instance of the local database available for the given identifier.
 * @throws BabuDBException 
 */
public DatabaseInternal getDatabase(int dbId) throws BabuDBException {
  return getDBMan().getDatabase(dbId);
}

Fixed version (ground truth):
/** 
 * @param dbId
 * @return an instance of the local database available for the given identifier.
 * @throws BabuDBException 
 */
public DatabaseProxy getDatabase(int dbId) throws BabuDBException {
  return dbMan.getDatabaseNonblocking(dbId);
}
Program: 132289
Project: 132289
Buggy source:
/** 
 * @return the {@link TransactionManagerInternal} of the local BabuDB instance.
 */
public TransactionManagerInternal getTransactionManager(){
  return dbs.getTransactionManager();
}

Fixed version (ground truth):
/** 
 * @return the {@link TransactionManagerProxy} of the local BabuDB instance.
 */
public TransactionManagerProxy getTransactionManager(){
  return (TransactionManagerProxy)dbs.getTransactionManager();
}
Program: 132290
Project: 132290
Buggy source:
/** 
 * @return the BabuDB modification lock object.
 */
public Object getDBModificationLock(){
  return getDBMan().getDBModificationLock();
}

Fixed version (ground truth):
/** 
 * @return the BabuDB modification lock object.
 */
public Object getDBModificationLock(){
  return dbs.getDatabaseManager().getDBModificationLock();
}
Program: 132291
Project: 132291
Buggy source:
@Override public BabuDBInternal start(BabuDBInternal babuDB,String configPath) throws BabuDBException {
  ReplicationConfig configuration;
  try {
    configuration=new ReplicationConfig(configPath,babuDB.getConfig());
  }
 catch (  IOException ioe) {
    throw new BabuDBException(ErrorCode.REPLICATION_FAILURE,"String_Node_Str",ioe.getCause());
  }
  try {
    new FileIO(configuration).replayBackupFiles();
  }
 catch (  IOException io) {
    Logging.logMessage(Logging.LEVEL_ERROR,this,"String_Node_Str" + "String_Node_Str",io.getMessage());
  }
  ReplicationManager replMan;
  try {
    replMan=new ReplicationManager(babuDB,configuration);
  }
 catch (  Exception e) {
    if (e.getMessage() == null)     Logging.logError(Logging.LEVEL_ERROR,this,e);
    throw new BabuDBException(ErrorCode.REPLICATION_FAILURE,e.getMessage(),e.getCause());
  }
  return new BabuDBProxy(babuDB,replMan,configuration.getReplicationPolicy());
}

Fixed version (ground truth):
@Override public BabuDBInternal start(BabuDBInternal babuDB,String configPath) throws BabuDBException {
  ReplicationConfig configuration;
  try {
    configuration=new ReplicationConfig(configPath,babuDB.getConfig());
  }
 catch (  IOException ioe) {
    throw new BabuDBException(ErrorCode.REPLICATION_FAILURE,"String_Node_Str",ioe.getCause());
  }
  try {
    new FileIO(configuration).replayBackupFiles();
  }
 catch (  IOException io) {
    Logging.logMessage(Logging.LEVEL_ERROR,this,"String_Node_Str" + "String_Node_Str",io.getMessage());
  }
  BabuDBInterface dbInterface=new BabuDBInterface(babuDB);
  ReplicationManager replMan;
  try {
    replMan=new ReplicationManager(configuration,dbInterface);
  }
 catch (  Exception e) {
    if (e.getMessage() == null)     Logging.logError(Logging.LEVEL_ERROR,this,e);
    throw new BabuDBException(ErrorCode.REPLICATION_FAILURE,e.getMessage(),e.getCause());
  }
  return new BabuDBProxy(babuDB,replMan,configuration.getReplicationPolicy(),dbInterface);
}
Program: 132292
Project: 132292
Buggy source:
/** 
 * <p>For setting up the   {@link BabuDB} with replication. Replication instance will be remaining stopped and in slave-mode.</p>
 * @param dbs
 * @param conf
 * @throws Exception 
 */
public ReplicationManager(BabuDBInternal dbs,ReplicationConfig conf) throws Exception {
  redirectIsVisible=conf.redirectIsVisible();
  TimeSync.initializeLocal(conf.getTimeSyncInterval(),conf.getLocalTimeRenew()).setLifeCycleListener(this);
  transmissionLayer=new TransmissionLayer(conf);
  serviceLayer=new ServiceLayer(conf,new BabuDBInterface(dbs),transmissionLayer);
  ControlLayer cl=new ControlLayer(serviceLayer,conf);
  controlLayer=cl;
  serviceLayer.init(controlLayer);
  transmissionLayer.setLifeCycleListener(this);
  serviceLayer.setLifeCycleListener(this);
  controlLayer.setLifeCycleListener(this);
}

Fixed version (ground truth):
/** 
 * <p>For setting up the   {@link BabuDB} with replication. Replication instance will be remaining stopped and in slave-mode.</p>
 * @param dbs
 * @param conf
 * @throws Exception 
 */
public ReplicationManager(ReplicationConfig conf,BabuDBInterface dbs) throws Exception {
  redirectIsVisible=conf.redirectIsVisible();
  TimeSync.initializeLocal(conf.getTimeSyncInterval(),conf.getLocalTimeRenew()).setLifeCycleListener(this);
  transmissionLayer=new TransmissionLayer(conf);
  serviceLayer=new ServiceLayer(conf,dbs,transmissionLayer);
  ControlLayer cl=new ControlLayer(serviceLayer,conf);
  controlLayer=cl;
  serviceLayer.init(controlLayer);
  transmissionLayer.setLifeCycleListener(this);
  serviceLayer.setLifeCycleListener(this);
  controlLayer.setLifeCycleListener(this);
}
Program: 132293
Project: 132293
Buggy source:
/** 
 * Blocking call.
 * @return the currently designated master.
 * @throws InterruptedException 
 */
public InetSocketAddress getMaster() throws InterruptedException {
  return controlLayer.getLeaseHolder(0);
}

Fixed version (ground truth):
/** 
 * Blocking call (for max. ReplicationConfig.REQUEST_TIMEOUT).
 * @param timeout - 0 for infinite blocking and < 0 for non-blocking.
 * @return the currently designated master.
 * @throws InterruptedException 
 */
public InetSocketAddress getMaster(int timeout) throws InterruptedException {
  return controlLayer.getLeaseHolder(timeout);
}
Program: 132294
Project: 132294
Buggy source:
@Override public void synced(LSN lsn){
  Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str",lsn.toString());
synchronized (finished) {
    if (finished.compareAndSet(false,true)) {
      finished.notify();
    }
 else {
      assert(false);
    }
  }
}

Fixed version (ground truth):
@Override public void synced(LSN lsn){
  Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str",lsn.toString());
  serviceInterface.reset();
synchronized (finished) {
    if (finished.compareAndSet(false,true)) {
      finished.notify();
    }
 else {
      assert(false);
    }
  }
}
Program: 132295
Project: 132295
Buggy source:
/** 
 * Enqueue a new failover request.
 * @param address - of the new replication master candidate.
 */
void queueFailoverRequest(InetSocketAddress address){
  Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str",thisAddress.toString(),address.toString());
synchronized (failoverRequest) {
    if (failoverRequest.compareAndSet(null,address)) {
      failoverRequest.notify();
    }
  }
}

Fixed version (ground truth):
/** 
 * Enqueue a new failover request.
 * @param address - of the new replication master candidate.
 */
void queueFailoverRequest(InetSocketAddress address){
synchronized (failoverRequest) {
    if (failoverRequest.compareAndSet(null,address)) {
      Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str",thisAddress.toString(),address.toString());
      failoverRequest.notify();
    }
  }
}
Program: 132296
Project: 132296
Buggy source:
/** 
 * This server has to become the new master.
 * @throws Exception
 */
private void becomeMaster() throws Exception {
  Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str");
  final AtomicBoolean finished=new AtomicBoolean(false);
  final AtomicReference<Exception> exception=new AtomicReference<Exception>(null);
  serviceInterface.synchronize(new SyncListener(){
    @Override public void synced(    LSN lsn){
      Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str",lsn.toString());
synchronized (finished) {
        if (finished.compareAndSet(false,true)) {
          finished.notify();
        }
 else {
          assert(false);
        }
      }
    }
    @Override public void failed(    Exception ex){
      Logging.logMessage(Logging.LEVEL_WARN,this,"String_Node_Str" + "String_Node_Str",ex.getMessage());
      Logging.logError(Logging.LEVEL_DEBUG,this,ex);
synchronized (finished) {
        if (finished.compareAndSet(false,true)) {
          exception.set(ex);
          finished.notify();
        }
 else {
          assert(false);
        }
      }
    }
  }
,thisAddress.getPort());
synchronized (finished) {
    while (!finished.get()) {
      finished.wait();
    }
    if (exception.get() != null) {
      throw exception.get();
    }
  }
}

Fixed version (ground truth):
/** 
 * This server has to become the new master.
 * @throws Exception
 */
private void becomeMaster() throws Exception {
  Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str");
  final AtomicBoolean finished=new AtomicBoolean(false);
  final AtomicReference<Exception> exception=new AtomicReference<Exception>(null);
  serviceInterface.synchronize(new SyncListener(){
    @Override public void synced(    LSN lsn){
      Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str",lsn.toString());
      serviceInterface.reset();
synchronized (finished) {
        if (finished.compareAndSet(false,true)) {
          finished.notify();
        }
 else {
          assert(false);
        }
      }
    }
    @Override public void failed(    Exception ex){
      Logging.logMessage(Logging.LEVEL_WARN,this,"String_Node_Str" + "String_Node_Str",ex.getMessage());
      Logging.logError(Logging.LEVEL_DEBUG,this,ex);
synchronized (finished) {
        if (finished.compareAndSet(false,true)) {
          exception.set(ex);
          finished.notify();
        }
 else {
          assert(false);
        }
      }
    }
  }
,thisAddress.getPort());
synchronized (finished) {
    while (!finished.get()) {
      finished.wait();
    }
    if (exception.get() != null) {
      throw exception.get();
    }
  }
}
Program: 132297
Project: 132297
Buggy source:
public BabuDBProxy(BabuDBInternal localDB,ReplicationManager replMan,Policy replicationPolicy){
  assert(localDB != null);
  this.localBabuDB=localDB;
  this.replMan=replMan;
  this.txnManProxy=new TransactionManagerProxy(replMan,localDB.getTransactionManager(),replicationPolicy,this);
  DatabaseManagerProxy dbMan=new DatabaseManagerProxy(localDB.getDatabaseManager(),replicationPolicy,replMan,this,txnManProxy,localDB.getResponseManager());
  this.client=replMan.getProxyClient(dbMan);
  this.dbManProxy=dbMan;
}

Fixed version (ground truth):
public BabuDBProxy(BabuDBInternal localDB,ReplicationManager replMan,Policy replicationPolicy,BabuDBInterface dbInt){
  assert(localDB != null);
  this.localBabuDB=localDB;
  this.replMan=replMan;
  this.txnManProxy=new TransactionManagerProxy(replMan,localDB.getTransactionManager(),replicationPolicy,this);
  DatabaseManagerProxy dbMan=new DatabaseManagerProxy(localDB.getDatabaseManager(),replicationPolicy,replMan,this,txnManProxy,localDB.getResponseManager());
  dbInt.init(dbMan);
  this.client=replMan.getProxyClient(dbMan);
  this.dbManProxy=dbMan;
}
Program: 132299
Project: 132299
Buggy source:
@Override public void replayTransaction(TransactionInternal txn) throws BabuDBException {
  for (  OperationInternal operation : txn) {
    byte type=operation.getType();
    if (type != Operation.TYPE_COPY_DB && type != Operation.TYPE_CREATE_DB && type != Operation.TYPE_DELETE_DB) {
      InMemoryProcessing processing=inMemoryProcessing.get(type);
      try {
        processing.process(operation);
      }
 catch (      BabuDBException be) {
        if (!(type == Operation.TYPE_CREATE_SNAP && be.getErrorCode() == ErrorCode.SNAP_EXISTS) && !(type == Operation.TYPE_DELETE_SNAP && be.getErrorCode() == ErrorCode.NO_SUCH_SNAPSHOT) && !(type == Operation.TYPE_GROUP_INSERT && be.getErrorCode().equals(ErrorCode.NO_SUCH_DB))) {
          throw be;
        }
      }
    }
  }
}

Fixed version (ground truth):
@Override public void replayTransaction(TransactionInternal txn) throws BabuDBException {
  for (  OperationInternal operation : txn) {
    byte type=operation.getType();
    if (type != Operation.TYPE_COPY_DB && type != Operation.TYPE_CREATE_DB && type != Operation.TYPE_DELETE_DB) {
      InMemoryProcessing processing=inMemoryProcessing.get(type);
      try {
        processing.process(operation);
      }
 catch (      BabuDBException be) {
        if (!(type == Operation.TYPE_CREATE_SNAP && (be.getErrorCode() == ErrorCode.SNAP_EXISTS || be.getErrorCode() == ErrorCode.NO_SUCH_DB)) && !(type == Operation.TYPE_DELETE_SNAP && be.getErrorCode() == ErrorCode.NO_SUCH_SNAPSHOT) && !(type == Operation.TYPE_GROUP_INSERT && be.getErrorCode().equals(ErrorCode.NO_SUCH_DB))) {
          throw be;
        }
      }
    }
  }
}
Program: 132300
Project: 132300
Buggy source:
public void free(){
  if (currentBlock != null && currentBlock.readBuffer.getRefCount() > 0)   currentBlock.free();
}

Fixed version (ground truth):
public void free(){
  if (currentBlock != null && currentBlock.readBuffer != null && currentBlock.readBuffer.getRefCount() > 0)   currentBlock.free();
}
Program: 132301
Project: 132301
Buggy source:
/** 
 * Executes a range lookup. The result object contains an iterator to the database starting at the first key greater or equal to <code>from</code> and returning key/value pairs in ascending order. <p> Note that <code>from</code> needs to be smaller than or equal to <code>to</code> according to the comparator associated with the index. </p>
 * @param indexId index id (0..NumIndices-1)
 * @param from the key to start the iterator at
 * @param to the key to end the iterator at
 * @param context arbitrary context which is passed to the listener.
 * @return a future as proxy for the request result.
 */
public DatabaseRequestResult<ResultSet<byte[],byte[]>> rangeLookup(int indexId,byte[] from,byte[] to,Object context);

Fixed version (ground truth):
/** 
 * Executes a range lookup. The result object contains an iterator to the database starting at the first key greater or equal to <code>from</code> and returning key/value pairs in ascending order. <p> Note that <code>from</code> needs to be smaller than or equal to <code>to</code> according to the comparator associated with the index. </p>
 * @param indexId index id (0..NumIndices-1)
 * @param from the key to start the iterator at (inclusively)
 * @param to the key to end the iterator at (exclusively)
 * @param context arbitrary context which is passed to the listener.
 * @return a future as proxy for the request result.
 */
public DatabaseRequestResult<ResultSet<byte[],byte[]>> rangeLookup(int indexId,byte[] from,byte[] to,Object context);
Program: 132302
Project: 132302
Buggy source:
/** 
 * Executes a range lookup. The result object contains an iterator to the database starting at the first key less or equal to <code>to</code> and returning key/value pairs in descending order. <p> Note that <code>from</code> needs to be larger than or equal to <code>to</code> according to the comparator associated with the index. </p>
 * @param indexId index id (0..NumIndices-1)
 * @param from the key to start the iterator at
 * @param to the key to end the iterator at
 * @param context arbitrary context which is passed to the listener.
 * @return a future as proxy for the request result.
 */
public DatabaseRequestResult<ResultSet<byte[],byte[]>> reverseRangeLookup(int indexId,byte[] from,byte[] to,Object context);

Fixed version (ground truth):
/** 
 * Executes a range lookup. The result object contains an iterator to the database starting at the first key less or equal to <code>to</code> and returning key/value pairs in descending order. <p> Note that <code>from</code> needs to be greater than or equal to <code>to</code> according to the comparator associated with the index. </p>
 * @param indexId index id (0..NumIndices-1)
 * @param from the key to start the iterator at (inclusively)
 * @param to the key to end the iterator at (exclusively)
 * @param context arbitrary context which is passed to the listener.
 * @return a future as proxy for the request result.
 */
public DatabaseRequestResult<ResultSet<byte[],byte[]>> reverseRangeLookup(int indexId,byte[] from,byte[] to,Object context);
Program: 132303
Project: 132303
Buggy source:
private void read(){
  int i=0;
  String path;
  while ((path=readOptionalString("String_Node_Str" + i++,null)) != null) {
    if (!path.endsWith("String_Node_Str") && !path.endsWith("String_Node_Str")) {
      if (path.contains("String_Node_Str")) {
        path=path + "String_Node_Str";
      }
 else       if (path.contains("String_Node_Str")) {
        path=path + "String_Node_Str";
      }
 else {
        path=path + File.separator;
      }
    }
    paths.add(path);
  }
}

Fixed version (ground truth):
private void read(){
  int i=0;
  String path;
  while ((path=readOptionalString("String_Node_Str" + i++,null)) != null) {
    paths.add(path);
  }
}
Program: 132307
Project: 132307
Buggy source:
@Test public void testUserDefinedLookup() throws Exception {
  database=BabuDBFactory.createBabuDB(new BabuDBConfig(baseDir,baseDir,1,0,0,SyncMode.SYNC_WRITE,0,0,compression,maxNumRecs,maxBlockFileSize));
  Database db=database.getDatabaseManager().createDatabase("String_Node_Str",3);
  DatabaseInsertGroup ir=db.createInsertGroup();
  ir.addInsert(0,"String_Node_Str".getBytes(),"String_Node_Str".getBytes());
  ir.addInsert(1,"String_Node_Str".getBytes(),"String_Node_Str".getBytes());
  ir.addInsert(2,"String_Node_Str".getBytes(),"String_Node_Str".getBytes());
  db.insert(ir,null).get();
  UserDefinedLookup lookup=new UserDefinedLookup(){
    public Object execute(    LSMLookupInterface database) throws BabuDBException {
      if ((database.lookup(0,"String_Node_Str".getBytes()) != null) && (database.lookup(1,"String_Node_Str".getBytes()) != null)) {
        return new Boolean(true);
      }
 else {
        return new Boolean(false);
      }
    }
  }
;
  Boolean result=(Boolean)db.userDefinedLookup(lookup,null).get();
  assertTrue(result);
  System.out.println("String_Node_Str");
  database.shutdown();
}

Fixed version (ground truth):
@Test public void testUserDefinedLookup() throws Exception {
  database=BabuDBFactory.createBabuDB(new BabuDBConfig(baseDir,baseDir,1,0,0,SyncMode.SYNC_WRITE,0,0,compression,maxNumRecs,maxBlockFileSize,true,0,Logging.LEVEL_DEBUG));
  Database db=database.getDatabaseManager().createDatabase("String_Node_Str",3);
  DatabaseInsertGroup ir=db.createInsertGroup();
  ir.addInsert(0,"String_Node_Str".getBytes(),"String_Node_Str".getBytes());
  ir.addInsert(1,"String_Node_Str".getBytes(),"String_Node_Str".getBytes());
  ir.addInsert(2,"String_Node_Str".getBytes(),"String_Node_Str".getBytes());
  db.insert(ir,null).get();
  UserDefinedLookup lookup=new UserDefinedLookup(){
    public Object execute(    LSMLookupInterface database) throws BabuDBException {
      if ((database.lookup(0,"String_Node_Str".getBytes()) != null) && (database.lookup(1,"String_Node_Str".getBytes()) != null)) {
        return new Boolean(true);
      }
 else {
        return new Boolean(false);
      }
    }
  }
;
  Boolean result=(Boolean)db.userDefinedLookup(lookup,null).get();
  assertTrue(result);
  System.out.println("String_Node_Str");
  database.shutdown();
}
Program: 132309
Project: 132309
Buggy source:
@Test public void testInsRangeLookup() throws Exception {
  database=BabuDBFactory.createBabuDB(new BabuDBConfig(baseDir,baseDir,0,0,0,SyncMode.ASYNC,0,0,compression,maxNumRecs,maxBlockFileSize));
  Database db=database.getDatabaseManager().createDatabase("String_Node_Str",3);
  for (int i=1000; i < 2000; i++) {
    DatabaseInsertGroup ir=db.createInsertGroup();
    ir.addInsert(0,(i + "String_Node_Str").getBytes(),(i + "String_Node_Str").getBytes());
    ir.addInsert(1,(i + "String_Node_Str").getBytes(),(i + "String_Node_Str").getBytes());
    ir.addInsert(2,(i + "String_Node_Str").getBytes(),(i + "String_Node_Str").getBytes());
    db.insert(ir,null);
  }
  Iterator<Entry<byte[],byte[]>> it=db.rangeLookup(0,new byte[0],new byte[0],null).get();
  for (int i=1000; i < 2000; i++)   assertEquals(i + "String_Node_Str",new String(it.next().getValue()));
  assertFalse(it.hasNext());
  it=db.rangeLookup(0,"String_Node_Str".getBytes(),"String_Node_Str".getBytes(),null).get();
  for (int i=1500; i < 1600; i++)   assertEquals(i + "String_Node_Str",new String(it.next().getValue()));
  assertFalse(it.hasNext());
  database.getCheckpointer().checkpoint();
  it=db.rangeLookup(0,"String_Node_Str".getBytes(),"String_Node_Str".getBytes(),null).get();
  for (int i=1500; i < 1600; i++)   assertEquals(i + "String_Node_Str",new String(it.next().getValue()));
  assertFalse(it.hasNext());
  database.shutdown();
}

Fixed version (ground truth):
@Test public void testInsRangeLookup() throws Exception {
  database=BabuDBFactory.createBabuDB(new BabuDBConfig(baseDir,baseDir,0,0,0,SyncMode.ASYNC,0,0,compression,maxNumRecs,maxBlockFileSize,true,0,Logging.LEVEL_DEBUG));
  Database db=database.getDatabaseManager().createDatabase("String_Node_Str",3);
  for (int i=1000; i < 2000; i++) {
    DatabaseInsertGroup ir=db.createInsertGroup();
    ir.addInsert(0,(i + "String_Node_Str").getBytes(),(i + "String_Node_Str").getBytes());
    ir.addInsert(1,(i + "String_Node_Str").getBytes(),(i + "String_Node_Str").getBytes());
    ir.addInsert(2,(i + "String_Node_Str").getBytes(),(i + "String_Node_Str").getBytes());
    db.insert(ir,null);
  }
  Iterator<Entry<byte[],byte[]>> it=db.rangeLookup(0,new byte[0],new byte[0],null).get();
  for (int i=1000; i < 2000; i++)   assertEquals(i + "String_Node_Str",new String(it.next().getValue()));
  assertFalse(it.hasNext());
  it=db.rangeLookup(0,"String_Node_Str".getBytes(),"String_Node_Str".getBytes(),null).get();
  for (int i=1500; i < 1600; i++)   assertEquals(i + "String_Node_Str",new String(it.next().getValue()));
  assertFalse(it.hasNext());
  database.getCheckpointer().checkpoint();
  it=db.rangeLookup(0,"String_Node_Str".getBytes(),"String_Node_Str".getBytes(),null).get();
  for (int i=1500; i < 1600; i++)   assertEquals(i + "String_Node_Str",new String(it.next().getValue()));
  assertFalse(it.hasNext());
  database.shutdown();
}
Program: 132310
Project: 132310
Buggy source:
@Test public void testDirectAccess() throws Exception {
  Logging.logMessage(Logging.LEVEL_DEBUG,Category.test,this,BufferPool.getStatus());
  database=BabuDBFactory.createBabuDB(new BabuDBConfig(baseDir,baseDir,0,0,0,SyncMode.ASYNC,0,50,compression,maxNumRecs,maxBlockFileSize));
  Database db=database.getDatabaseManager().createDatabase("String_Node_Str",2);
  for (int i=0; i < 100000; i++) {
    DatabaseInsertGroup ir=db.createInsertGroup();
    ir.addInsert(0,(i + "String_Node_Str").getBytes(),"String_Node_Str".getBytes());
    ir.addInsert(1,(i + "String_Node_Str").getBytes(),"String_Node_Str".getBytes());
    db.insert(ir,null).get();
  }
  Logging.logMessage(Logging.LEVEL_DEBUG,Category.test,this,BufferPool.getStatus());
  database.getCheckpointer().checkpoint();
  for (int i=0; i < 100000; i++) {
    byte[] v0=db.lookup(0,(i + "String_Node_Str").getBytes(),null).get();
    byte[] v1=db.lookup(1,(i + "String_Node_Str").getBytes(),null).get();
    assertEquals("String_Node_Str",new String(v0));
    assertEquals("String_Node_Str",new String(v1));
  }
  Logging.logMessage(Logging.LEVEL_DEBUG,Category.test,this,BufferPool.getStatus());
}

Fixed version (ground truth):
@Test public void testDirectAccess() throws Exception {
  Logging.logMessage(Logging.LEVEL_DEBUG,Category.test,this,BufferPool.getStatus());
  database=BabuDBFactory.createBabuDB(new BabuDBConfig(baseDir,baseDir,0,0,0,SyncMode.ASYNC,0,50,compression,maxNumRecs,maxBlockFileSize,true,0,Logging.LEVEL_DEBUG));
  Database db=database.getDatabaseManager().createDatabase("String_Node_Str",2);
  for (int i=0; i < 100000; i++) {
    DatabaseInsertGroup ir=db.createInsertGroup();
    ir.addInsert(0,(i + "String_Node_Str").getBytes(),"String_Node_Str".getBytes());
    ir.addInsert(1,(i + "String_Node_Str").getBytes(),"String_Node_Str".getBytes());
    db.insert(ir,null).get();
  }
  Logging.logMessage(Logging.LEVEL_DEBUG,Category.test,this,BufferPool.getStatus());
  database.getCheckpointer().checkpoint();
  for (int i=0; i < 100000; i++) {
    byte[] v0=db.lookup(0,(i + "String_Node_Str").getBytes(),null).get();
    byte[] v1=db.lookup(1,(i + "String_Node_Str").getBytes(),null).get();
    assertEquals("String_Node_Str",new String(v0));
    assertEquals("String_Node_Str",new String(v1));
  }
  Logging.logMessage(Logging.LEVEL_DEBUG,Category.test,this,BufferPool.getStatus());
  database.shutdown();
}
Program: 132312
Project: 132312
Buggy source:
@Test public void testInsPrefLookup() throws Exception {
  database=BabuDBFactory.createBabuDB(new BabuDBConfig(baseDir,baseDir,0,0,0,SyncMode.ASYNC,0,0,compression,maxNumRecs,maxBlockFileSize));
  Database db=database.getDatabaseManager().createDatabase("String_Node_Str",3);
  for (int i=1000; i < 2000; i++) {
    DatabaseInsertGroup ir=db.createInsertGroup();
    ir.addInsert(0,(i + "String_Node_Str").getBytes(),(i + "String_Node_Str").getBytes());
    ir.addInsert(1,(i + "String_Node_Str").getBytes(),(i + "String_Node_Str").getBytes());
    ir.addInsert(2,(i + "String_Node_Str").getBytes(),(i + "String_Node_Str").getBytes());
    db.insert(ir,null);
  }
  Iterator<Entry<byte[],byte[]>> it=db.prefixLookup(0,new byte[0],null).get();
  for (int i=1000; i < 2000; i++)   assertEquals(i + "String_Node_Str",new String(it.next().getValue()));
  assertFalse(it.hasNext());
  it=db.prefixLookup(0,"String_Node_Str".getBytes(),null).get();
  for (int i=1500; i < 1600; i++)   assertEquals(i + "String_Node_Str",new String(it.next().getValue()));
  assertFalse(it.hasNext());
  database.getCheckpointer().checkpoint();
  it=db.prefixLookup(0,"String_Node_Str".getBytes(),null).get();
  for (int i=1500; i < 1600; i++)   assertEquals(i + "String_Node_Str",new String(it.next().getValue()));
  assertFalse(it.hasNext());
  database.shutdown();
}

Fixed version (ground truth):
@Test public void testInsPrefLookup() throws Exception {
  database=BabuDBFactory.createBabuDB(new BabuDBConfig(baseDir,baseDir,0,0,0,SyncMode.ASYNC,0,0,compression,maxNumRecs,maxBlockFileSize,true,0,Logging.LEVEL_DEBUG));
  Database db=database.getDatabaseManager().createDatabase("String_Node_Str",3);
  for (int i=1000; i < 2000; i++) {
    DatabaseInsertGroup ir=db.createInsertGroup();
    ir.addInsert(0,(i + "String_Node_Str").getBytes(),(i + "String_Node_Str").getBytes());
    ir.addInsert(1,(i + "String_Node_Str").getBytes(),(i + "String_Node_Str").getBytes());
    ir.addInsert(2,(i + "String_Node_Str").getBytes(),(i + "String_Node_Str").getBytes());
    db.insert(ir,null);
  }
  Iterator<Entry<byte[],byte[]>> it=db.prefixLookup(0,new byte[0],null).get();
  for (int i=1000; i < 2000; i++)   assertEquals(i + "String_Node_Str",new String(it.next().getValue()));
  assertFalse(it.hasNext());
  it=db.prefixLookup(0,"String_Node_Str".getBytes(),null).get();
  for (int i=1500; i < 1600; i++)   assertEquals(i + "String_Node_Str",new String(it.next().getValue()));
  assertFalse(it.hasNext());
  database.getCheckpointer().checkpoint();
  it=db.prefixLookup(0,"String_Node_Str".getBytes(),null).get();
  for (int i=1500; i < 1600; i++)   assertEquals(i + "String_Node_Str",new String(it.next().getValue()));
  assertFalse(it.hasNext());
  database.shutdown();
}
Program: 132313
Project: 132313
Buggy source:
@Test public void testMultipleIndices() throws Exception {
  database=BabuDBFactory.createBabuDB(new BabuDBConfig(baseDir,baseDir,1,0,0,SyncMode.SYNC_WRITE,0,0,compression,maxNumRecs,maxBlockFileSize));
  Database db=database.getDatabaseManager().createDatabase("String_Node_Str",3);
  DatabaseInsertGroup ir=db.createInsertGroup();
  ir.addInsert(0,"String_Node_Str".getBytes(),"String_Node_Str".getBytes());
  ir.addInsert(1,"String_Node_Str".getBytes(),"String_Node_Str".getBytes());
  ir.addInsert(2,"String_Node_Str".getBytes(),"String_Node_Str".getBytes());
  db.insert(ir,null).get();
  database.getCheckpointer().checkpoint();
  database.shutdown();
  database=BabuDBFactory.createBabuDB(new BabuDBConfig(baseDir,baseDir,2,0,0,SyncMode.SYNC_WRITE,0,0,compression,maxNumRecs,maxBlockFileSize));
  db=database.getDatabaseManager().getDatabase("String_Node_Str");
  byte[] result=db.lookup(0,"String_Node_Str".getBytes(),null).get();
  assertNotNull(result);
  String value=new String(result);
  assertEquals(value,"String_Node_Str");
  result=db.lookup(1,"String_Node_Str".getBytes(),null).get();
  assertNotNull(result);
  value=new String(result);
  assertEquals(value,"String_Node_Str");
  result=db.lookup(2,"String_Node_Str".getBytes(),null).get();
  assertNotNull(result);
  value=new String(result);
  assertEquals(value,"String_Node_Str");
  System.out.println("String_Node_Str");
  database.shutdown();
}

Fixed version (ground truth):
@Test public void testMultipleIndices() throws Exception {
  database=BabuDBFactory.createBabuDB(new BabuDBConfig(baseDir,baseDir,1,0,0,SyncMode.SYNC_WRITE,0,0,compression,maxNumRecs,maxBlockFileSize,true,0,Logging.LEVEL_DEBUG));
  Database db=database.getDatabaseManager().createDatabase("String_Node_Str",3);
  DatabaseInsertGroup ir=db.createInsertGroup();
  ir.addInsert(0,"String_Node_Str".getBytes(),"String_Node_Str".getBytes());
  ir.addInsert(1,"String_Node_Str".getBytes(),"String_Node_Str".getBytes());
  ir.addInsert(2,"String_Node_Str".getBytes(),"String_Node_Str".getBytes());
  db.insert(ir,null).get();
  database.getCheckpointer().checkpoint();
  database.shutdown();
  database=BabuDBFactory.createBabuDB(new BabuDBConfig(baseDir,baseDir,2,0,0,SyncMode.SYNC_WRITE,0,0,compression,maxNumRecs,maxBlockFileSize));
  db=database.getDatabaseManager().getDatabase("String_Node_Str");
  byte[] result=db.lookup(0,"String_Node_Str".getBytes(),null).get();
  assertNotNull(result);
  String value=new String(result);
  assertEquals(value,"String_Node_Str");
  result=db.lookup(1,"String_Node_Str".getBytes(),null).get();
  assertNotNull(result);
  value=new String(result);
  assertEquals(value,"String_Node_Str");
  result=db.lookup(2,"String_Node_Str".getBytes(),null).get();
  assertNotNull(result);
  value=new String(result);
  assertEquals(value,"String_Node_Str");
  System.out.println("String_Node_Str");
  database.shutdown();
}
Program: 132315
Project: 132315
Buggy source:
public void failed(LogEntry entry,Exception ex){
synchronized (entry) {
    count.incrementAndGet();
    entry.notifyAll();
  }
}

Fixed version (ground truth):
public void failed(LogEntry entry,Exception ex){
synchronized (entry) {
    System.err.println(ex);
    count.incrementAndGet();
    entry.notifyAll();
  }
}
Program: 132316
Project: 132316
Buggy source:
@Test public void testReadLogfile() throws Exception {
  final AtomicInteger count=new AtomicInteger(0);
  SyncListener sl=new SyncListener(){
    public void synced(    LogEntry entry){
synchronized (entry) {
        count.incrementAndGet();
        entry.notifyAll();
        System.out.println("String_Node_Str" + entry.getLogSequenceNo());
      }
    }
    public void failed(    LogEntry entry,    Exception ex){
synchronized (entry) {
        count.incrementAndGet();
        entry.notifyAll();
      }
    }
  }
;
  LogEntry e=null;
  for (int i=0; i < 100; i++) {
    String pl="String_Node_Str" + (i + 1);
    ReusableBuffer plb=ReusableBuffer.wrap(pl.getBytes());
    e=new LogEntry(plb,sl,LogEntry.PAYLOAD_TYPE_INSERT);
    l.append(e);
  }
synchronized (e) {
    if (count.get() < 100)     e.wait(1000);
  }
  e.free();
  System.out.println("String_Node_Str");
  try {
    l.lockLogger();
    l.switchLogFile(false);
  }
  finally {
    l.unlockLogger();
  }
  DiskLogFile f=new DiskLogFile(testdir + "String_Node_Str");
  while (f.hasNext()) {
    LogEntry tmp=f.next();
    byte[] data=tmp.getPayload().array();
    String s=new String(data);
    System.out.println("String_Node_Str" + s);
    tmp.free();
  }
}

Fixed version (ground truth):
@Test public void testReadLogfile() throws Exception {
  final AtomicInteger count=new AtomicInteger(0);
  SyncListener sl=new SyncListener(){
    public void synced(    LogEntry entry){
synchronized (entry) {
        count.incrementAndGet();
        entry.notifyAll();
      }
    }
    public void failed(    LogEntry entry,    Exception ex){
synchronized (entry) {
        count.incrementAndGet();
        entry.notifyAll();
      }
    }
  }
;
  LogEntry e=null;
  for (int i=0; i < 100; i++) {
    String pl="String_Node_Str" + (i + 1);
    ReusableBuffer plb=ReusableBuffer.wrap(pl.getBytes());
    e=new LogEntry(plb,sl,LogEntry.PAYLOAD_TYPE_INSERT);
    l.append(e);
  }
synchronized (e) {
    if (count.get() < 100)     e.wait(1000);
  }
  e.free();
  System.out.println("String_Node_Str");
  try {
    l.lockLogger();
    l.switchLogFile(false);
  }
  finally {
    l.unlockLogger();
  }
  DiskLogFile f=new DiskLogFile(testdir + "String_Node_Str");
  while (f.hasNext()) {
    LogEntry tmp=f.next();
    byte[] data=tmp.getPayload().array();
    String s=new String(data);
    tmp.free();
  }
}
Program: 132317
Project: 132317
Buggy source:
public void free(){
  if (currentBlock != null) {
    currentBlock.free();
  }
}

Fixed version (ground truth):
public void free(){
  if (currentBlock != null && currentBlock.readBuffer.getRefCount() > 0)   currentBlock.free();
}
Program: 132318
Project: 132318
Buggy source:
/** 
 * Loads all classes from the jar found at path to be available to the ClassLoader.
 * @param path
 * @param classToSearchFor
 * @throws IOException 
 * @throws FileNotFoundException 
 */
private final String loadJar(String path,String classToSearchFor) throws FileNotFoundException, IOException {
  JarInputStream jis=new JarInputStream(new FileInputStream(path));
  JarEntry next=null;
  String main=null;
  while ((next=jis.getNextJarEntry()) != null) {
    if (!next.getName().endsWith("String_Node_Str")) {
      continue;
    }
    byte[] buf=new byte[4096];
    ByteArrayOutputStream out=new ByteArrayOutputStream();
    int len=-1;
    while ((len=jis.read(buf)) > 0) {
      out.write(buf,0,len);
    }
    String className=next.getName().substring(0,next.getName().length() - "String_Node_Str".length()).replace('/','.');
    if (classToSearchFor != null && className.endsWith(classToSearchFor)) {
      assert(main == null);
      main=className;
    }
    if (!classes.containsKey(className)) {
      classes.put(className,out.toByteArray());
    }
 else {
      Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str" + "String_Node_Str",className,path);
    }
    out.close();
  }
  jis.close();
  return main;
}

Fixed version (ground truth):
/** 
 * Loads all classes from the jar found at path to be available to the ClassLoader.
 * @param path
 * @param classToSearchFor
 * @throws IOException 
 * @throws FileNotFoundException 
 */
private final String loadJar(String path,String classToSearchFor) throws FileNotFoundException, IOException {
  JarInputStream jis=new JarInputStream(new FileInputStream(path));
  JarEntry next=null;
  String main=null;
  while ((next=jis.getNextJarEntry()) != null) {
    if (!next.getName().endsWith("String_Node_Str")) {
      continue;
    }
    byte[] buf=new byte[4096];
    ByteArrayOutputStream out=new ByteArrayOutputStream();
    int len=-1;
    while ((len=jis.read(buf)) > 0) {
      out.write(buf,0,len);
    }
    String className=next.getName().substring(0,next.getName().length() - "String_Node_Str".length()).replace('/','.');
    if (classToSearchFor != null && className.endsWith(classToSearchFor)) {
      assert(main == null);
      main=className;
    }
    if (!clazzes.containsKey(className)) {
      clazzes.put(className,out.toByteArray());
    }
 else {
      Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str" + "String_Node_Str",className,path);
    }
    out.close();
  }
  jis.close();
  return main;
}
Program: 132319
Project: 132319
Buggy source:
@Override public Class<?> loadClass(String name,boolean resolve) throws ClassNotFoundException {
  Class<?> clazz=null;
  try {
    clazz=findSystemClass(name);
  }
 catch (  Throwable t) {
    clazz=findLoadedClass(name);
    if (clazz == null) {
      byte[] classBytes=classes.get(name);
      if (classBytes != null) {
        clazz=defineClass(name,classBytes,0,classBytes.length);
      }
 else {
        throw new ClassNotFoundException(t.getMessage(),t);
      }
    }
  }
  if (resolve) {
    resolveClass(clazz);
  }
  return clazz;
}

Fixed version (ground truth):
@Override public Class<?> loadClass(String name,boolean resolve) throws ClassNotFoundException {
  Class<?> clazz=findLoadedClass(name);
  if (clazz == null) {
    byte[] classBytes=clazzes.get(name);
    if (classBytes != null) {
      clazz=defineClass(name,classBytes,0,classBytes.length);
    }
 else {
      clazz=getParent().loadClass(name);
    }
  }
  if (resolve) {
    resolveClass(clazz);
  }
  return clazz;
}
Program: 132320
Project: 132320
Buggy source:
/** 
 * Creates a BabuDB JAR class loader for the plugins defined within the configuration file. It will automatically attempt to load its JAR  for the given data version.
 * @param babuDBImpl
 * @throws IOException if an I/O error occurred
 */
private PluginLoader(BabuDBInternal dbs) throws IOException {
  super();
  this.babuDB=dbs;
  for (  Entry<String,String> plugin : dbs.getConfig().getPlugins().entrySet()) {
    String main=null;
    String pluginPath=plugin.getKey();
    String configPath=plugin.getValue();
    try {
      main=loadJar(pluginPath,"String_Node_Str");
      if (main == null) {
        throw new Exception("String_Node_Str");
      }
      PluginMain m=(PluginMain)loadClass(main).newInstance();
      for (      String depPath : m.getDependencies(configPath)) {
        loadJar(depPath);
      }
      babuDB=m.execute(babuDB,configPath);
    }
 catch (    Exception e) {
      throw new IOException("String_Node_Str" + pluginPath + "String_Node_Str"+ BABUDB_VERSION+ ((configPath != null) ? "String_Node_Str" + configPath : "String_Node_Str")+ "String_Node_Str"+ e.getMessage()+ "String_Node_Str",e.getCause());
    }
  }
}

Fixed version (ground truth):
/** 
 * Creates a BabuDB JAR class loader for the plugins defined within the configuration file. It will automatically attempt to load its JAR  for the given data version.
 * @param babuDBImpl
 * @throws IOException if an I/O error occurred
 */
private PluginLoader(BabuDBInternal dbs) throws IOException {
  super();
  this.babuDB=dbs;
  for (  Entry<String,String> plugin : dbs.getConfig().getPlugins().entrySet()) {
    String main=null;
    String pluginPath=plugin.getKey();
    String configPath=plugin.getValue();
    try {
      main=loadJar(pluginPath,"String_Node_Str");
      if (main == null) {
        throw new Exception("String_Node_Str");
      }
      PluginMain m=(PluginMain)loadClass(main).newInstance();
      for (      String depPath : m.getDependencies(configPath)) {
        Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str",depPath);
        loadJar(depPath);
      }
      babuDB=m.execute(babuDB,configPath);
    }
 catch (    Exception e) {
      throw new IOException("String_Node_Str" + pluginPath + "String_Node_Str"+ BABUDB_VERSION+ ((configPath != null) ? "String_Node_Str" + configPath : "String_Node_Str")+ "String_Node_Str"+ e.getMessage()+ "String_Node_Str",e.getCause());
    }
  }
}
Program: 132322
Project: 132322
Buggy source:
/** 
 * Initializes the basic components of the BabuDB database system.
 * @param configuration
 * @throws BabuDBException
 */
BabuDBImpl(BabuDBConfig configuration) throws BabuDBException {
  this.configuration=configuration;
  this.databaseManager=new DatabaseManagerImpl(this);
  this.dbConfigFile=new DBConfig(this);
  this.snapshotManager=new SnapshotManagerImpl(this);
  this.dbCheckptr=new CheckpointerImpl(this);
  this.permMan=new PersistenceManagerImpl();
}

Fixed version (ground truth):
/** 
 * Initializes the basic components of the BabuDB database system.
 * @param configuration
 * @throws BabuDBException
 */
BabuDBImpl(BabuDBConfig configuration) throws BabuDBException {
  this.configuration=configuration;
  this.permMan=new PersistenceManagerImpl();
  this.databaseManager=new DatabaseManagerImpl(this);
  this.dbConfigFile=new DBConfig(this);
  this.snapshotManager=new SnapshotManagerImpl(this);
  this.dbCheckptr=new CheckpointerImpl(this);
}
Program: 132324
Project: 132324
Buggy source:
/** 
 * Insert an group of inserts in the context of the invoking thread. Proper insertion is not guaranteed, since the result of the attempt to make the insert persistent is ignored, if   {@link SyncMode} is ASYNC.
 * @param irg - the group of inserts.
 * @param listener - to notify after insert.
 */
private void directInsert(BabuDBInsertGroup irg,BabuDBRequestResultImpl<Object> listener){
  try {
    dbs.getPersistenceManager().makePersistent(PAYLOAD_TYPE_INSERT,new Object[]{irg,lsmDB,listener});
    if (dbs.getConfig().getSyncMode() == SyncMode.ASYNC) {
      for (      InsertRecord ir : irg.getRecord().getInserts()) {
        LSMTree index=lsmDB.getIndex(ir.getIndexId());
        if (ir.getValue() != null) {
          index.insert(ir.getKey(),ir.getValue());
        }
 else {
          index.delete(ir.getKey());
        }
      }
      listener.finished();
    }
  }
 catch (  BabuDBException e) {
    listener.failed(e);
  }
}

Fixed version (ground truth):
/** 
 * Insert an group of inserts in the context of the invoking thread. Proper insertion is not guaranteed, since the result of the attempt to make the insert persistent is ignored, if   {@link SyncMode} is ASYNC.
 * @param irg - the group of inserts.
 * @param listener - to notify after insert.
 */
private void directInsert(BabuDBInsertGroup irg,BabuDBRequestResultImpl<Object> listener){
  try {
    dbs.getPersistenceManager().makePersistent(PAYLOAD_TYPE_INSERT,new Object[]{irg.getRecord(),lsmDB,listener});
    if (dbs.getConfig().getSyncMode() == SyncMode.ASYNC) {
      for (      InsertRecord ir : irg.getRecord().getInserts()) {
        LSMTree index=lsmDB.getIndex(ir.getIndexId());
        if (ir.getValue() != null) {
          index.insert(ir.getKey(),ir.getValue());
        }
 else {
          index.delete(ir.getKey());
        }
      }
      listener.finished();
    }
  }
 catch (  BabuDBException e) {
    listener.failed(e);
  }
}
Program: 132325
Project: 132325
Buggy source:
@Override public void before(Object[] args) throws BabuDBException {
  BabuDBInsertGroup irg=(BabuDBInsertGroup)args[0];
  LSMDatabase lsmDB=(LSMDatabase)args[1];
  if (lsmDB == null) {
    lsmDB=((DatabaseImpl)dbsById.get(irg.getRecord().getDatabaseId())).getLSMDB();
  }
  int numIndices=lsmDB.getIndexCount();
  for (  InsertRecord ir : irg.getRecord().getInserts()) {
    if ((ir.getIndexId() >= numIndices) || (ir.getIndexId() < 0)) {
      throw new BabuDBException(ErrorCode.NO_SUCH_INDEX,"String_Node_Str" + ir.getIndexId() + "String_Node_Str");
    }
  }
}

Fixed version (ground truth):
@Override public void before(Object[] args) throws BabuDBException {
  InsertRecordGroup irg=(InsertRecordGroup)args[0];
  LSMDatabase lsmDB=(LSMDatabase)args[1];
  if (lsmDB == null) {
    lsmDB=((DatabaseImpl)dbsById.get(irg.getDatabaseId())).getLSMDB();
  }
  int numIndices=lsmDB.getIndexCount();
  for (  InsertRecord ir : irg.getInserts()) {
    if ((ir.getIndexId() >= numIndices) || (ir.getIndexId() < 0)) {
      throw new BabuDBException(ErrorCode.NO_SUCH_INDEX,"String_Node_Str" + ir.getIndexId() + "String_Node_Str");
    }
  }
}
Program: 132327
Project: 132327
Buggy source:
@Override public ReusableBuffer serializeRequest(Object[] args) throws BabuDBException {
  BabuDBInsertGroup irg=(BabuDBInsertGroup)args[0];
  int size=irg.getRecord().getSize();
  ReusableBuffer buf=BufferPool.allocate(size);
  irg.getRecord().serialize(buf);
  buf.flip();
  return buf;
}

Fixed version (ground truth):
@Override public ReusableBuffer serializeRequest(Object[] args) throws BabuDBException {
  InsertRecordGroup irg=(InsertRecordGroup)args[0];
  int size=irg.getSize();
  ReusableBuffer buf=BufferPool.allocate(size);
  irg.serialize(buf);
  buf.flip();
  return buf;
}