Program: 132323
Project: 132323
Buggy source:
/** 
 * Replays the database operations log.
 * @param from - LSN to replay the logs from.
 * @return the LSN to assign to the next operation
 * @throws BabuDBException
 */
private LSN replayLogs(LSN from) throws BabuDBException {
  try {
    File f=new File(configuration.getDbLogDir());
    File[] logFiles=f.listFiles(new FilenameFilter(){
      public boolean accept(      File dir,      String name){
        return name.endsWith("String_Node_Str");
      }
    }
);
    DiskLogIterator it=new DiskLogIterator(logFiles,from);
    LSN nextLSN=null;
    while (it.hasNext()) {
      LogEntry le=null;
      try {
        le=it.next();
switch (le.getPayloadType()) {
case LogEntry.PAYLOAD_TYPE_INSERT:
          InsertRecordGroup ai=InsertRecordGroup.deserialize(le.getPayload());
        databaseManager.insert(ai);
      break;
case LogEntry.PAYLOAD_TYPE_SNAP:
    ObjectInputStream oin=null;
  try {
    oin=new ObjectInputStream(new ByteArrayInputStream(le.getPayload().array()));
    int dbId=oin.readInt();
    SnapshotConfig snap=(SnapshotConfig)oin.readObject();
    Database db=databaseManager.getDatabase(dbId);
    if (db == null)     break;
    snapshotManager.createPersistentSnapshot(db.getName(),snap,false);
  }
 catch (  Exception e) {
    throw new BabuDBException(ErrorCode.IO_ERROR,"String_Node_Str" + e.getMessage(),e);
  }
 finally {
    if (oin != null)     oin.close();
  }
break;
case LogEntry.PAYLOAD_TYPE_SNAP_DELETE:
byte[] payload=le.getPayload().array();
int offs=payload[0];
String dbName=new String(payload,1,offs);
String snapName=new String(payload,offs + 1,payload.length - offs - 1);
snapshotManager.deletePersistentSnapshot(dbName,snapName,false);
break;
default :
break;
}
nextLSN=new LSN(le.getViewId(),le.getLogSequenceNo() + 1L);
}
  finally {
if (le != null) le.free();
}
}
it.destroy();
if (nextLSN != null) {
return nextLSN;
}
 else {
return new LSN(1,1);
}
}
 catch (IOException ex) {
throw new BabuDBException(ErrorCode.IO_ERROR,"String_Node_Str" + "String_Node_Str",ex);
}
catch (Exception ex) {
if (ex.getCause() instanceof LogEntryException) {
throw new BabuDBException(ErrorCode.IO_ERROR,"String_Node_Str" + "String_Node_Str",ex.getCause());
}
 else throw new BabuDBException(ErrorCode.IO_ERROR,"String_Node_Str" + "String_Node_Str",ex);
}
}

Fixed version (ground truth):
/** 
 * Replays the database operations log.
 * @param from - LSN to replay the logs from.
 * @return the LSN to assign to the next operation
 * @throws BabuDBException
 */
private LSN replayLogs(LSN from) throws BabuDBException {
  try {
    File f=new File(configuration.getDbLogDir());
    File[] logFiles=f.listFiles(new FilenameFilter(){
      public boolean accept(      File dir,      String name){
        return name.endsWith("String_Node_Str");
      }
    }
);
    DiskLogIterator it=new DiskLogIterator(logFiles,from);
    LSN nextLSN=null;
    while (it.hasNext()) {
      LogEntry le=null;
      try {
        le=it.next();
        InMemoryProcessing processingLogic=permMan.getProcessingLogic().get(le.getPayloadType());
        Object[] arguments=processingLogic.deserializeRequest(le.getPayload());
        processingLogic.before(arguments);
        processingLogic.after(arguments);
        nextLSN=new LSN(le.getViewId(),le.getLogSequenceNo() + 1L);
      }
  finally {
        if (le != null)         le.free();
      }
    }
    it.destroy();
    if (nextLSN != null) {
      return nextLSN;
    }
 else {
      return new LSN(1,1);
    }
  }
 catch (  IOException ex) {
    throw new BabuDBException(ErrorCode.IO_ERROR,"String_Node_Str" + "String_Node_Str",ex);
  }
catch (  Exception ex) {
    if (ex.getCause() instanceof LogEntryException) {
      throw new BabuDBException(ErrorCode.IO_ERROR,"String_Node_Str" + "String_Node_Str",ex.getCause());
    }
 else     throw new BabuDBException(ErrorCode.IO_ERROR,"String_Node_Str" + "String_Node_Str",ex);
  }
}