Program: 132451
Project: 132451
Buggy source:
public void directInsert(BabuDBInsertGroup irg) throws BabuDBException {
  final LSMDatabase db=databases.get(irg.getRecord().getDatabaseId());
  if (db == null) {
    throw new BabuDBException(ErrorCode.NO_SUCH_DB,"String_Node_Str");
  }
  final int numIndices=db.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");
    }
  }
  int size=irg.getRecord().getSize();
  ReusableBuffer buf=BufferPool.allocate(size);
  irg.getRecord().serialize(buf);
  buf.flip();
  final AsyncResult result=new AsyncResult();
  LogEntry e=new LogEntry(buf,new SyncListener(){
    public void synced(    LogEntry entry){
synchronized (result) {
        result.done=true;
        result.notifyAll();
      }
    }
    public void failed(    LogEntry entry,    Exception ex){
synchronized (result) {
        result.done=true;
        result.error=new BabuDBException(ErrorCode.IO_ERROR,"String_Node_Str",ex);
        result.notifyAll();
      }
    }
  }
);
  try {
    logger.append(e);
  }
 catch (  InterruptedException ex) {
    throw new BabuDBException(ErrorCode.INTERNAL_ERROR,"String_Node_Str",ex);
  }
synchronized (result) {
    if (!result.done) {
      try {
        result.wait();
      }
 catch (      InterruptedException ex) {
        throw new BabuDBException(ErrorCode.INTERNAL_ERROR,"String_Node_Str",ex);
      }
    }
  }
  if (result.error != null) {
    throw result.error;
  }
  for (  InsertRecord ir : irg.getRecord().getInserts()) {
    final LSMTree index=db.getIndex(ir.getIndexId());
    if (ir.getValue() != null) {
      index.insert(ir.getKey(),ir.getValue());
    }
 else {
      index.delete(ir.getKey());
    }
  }
}

Fixed version (ground truth):
public void directInsert(BabuDBInsertGroup irg) throws BabuDBException {
  final LSMDatabase db=databases.get(irg.getRecord().getDatabaseId());
  if (db == null) {
    throw new BabuDBException(ErrorCode.NO_SUCH_DB,"String_Node_Str");
  }
  final int numIndices=db.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");
    }
  }
  int size=irg.getRecord().getSize();
  ReusableBuffer buf=BufferPool.allocate(size);
  irg.getRecord().serialize(buf);
  buf.flip();
  final AsyncResult result=new AsyncResult();
  LogEntry e=new LogEntry(buf,new SyncListener(){
    public void synced(    LogEntry entry){
synchronized (result) {
        result.done=true;
        result.notifyAll();
      }
    }
    public void failed(    LogEntry entry,    Exception ex){
synchronized (result) {
        result.done=true;
        result.error=new BabuDBException(ErrorCode.IO_ERROR,"String_Node_Str",ex);
        result.notifyAll();
      }
    }
  }
);
  try {
    logger.append(e);
  }
 catch (  InterruptedException ex) {
    throw new BabuDBException(ErrorCode.INTERNAL_ERROR,"String_Node_Str",ex);
  }
synchronized (result) {
    if (!result.done) {
      try {
        result.wait();
      }
 catch (      InterruptedException ex) {
        throw new BabuDBException(ErrorCode.INTERNAL_ERROR,"String_Node_Str",ex);
      }
    }
  }
  if (result.error != null) {
    throw result.error;
  }
  e.free();
  for (  InsertRecord ir : irg.getRecord().getInserts()) {
    final LSMTree index=db.getIndex(ir.getIndexId());
    if (ir.getValue() != null) {
      index.insert(ir.getKey(),ir.getValue());
    }
 else {
      index.delete(ir.getKey());
    }
  }
}