Program: 132329
Project: 132329
Buggy source:
/** 
 * Load the most recent snapshots of each tree.
 * @param numIndices the number of indices to read.
 * @throws java.io.IOException if the on-disk data cannot be read
 */
private void loadFromDisk(int numIndices) throws BabuDBException {
  Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + this.databaseName + "String_Node_Str");
  for (int index=0; index < numIndices; index++) {
    trees.add(null);
  }
  for (int index=0; index < numIndices; index++) {
    final int idx=index;
    File f=new File(databaseDir);
    String[] files=f.list(new FilenameFilter(){
      public boolean accept(      File dir,      String name){
        return name.startsWith("String_Node_Str" + idx + "String_Node_Str");
      }
    }
);
    if (files == null)     throw new BabuDBException(ErrorCode.IO_ERROR,"String_Node_Str" + databaseDir + "String_Node_Str");
    int maxView=-1;
    int maxSeq=-1;
    Pattern p=Pattern.compile(SNAPSHOT_FILENAME_REGEXP);
    for (    String fname : files) {
      Matcher m=p.matcher(fname);
      m.matches();
      Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + fname);
      int view=Integer.valueOf(m.group(2));
      int seq=Integer.valueOf(m.group(3));
      if (view > maxView) {
        maxView=view;
        maxSeq=seq;
      }
 else       if (view == maxView) {
        if (seq > maxSeq)         maxSeq=seq;
      }
    }
    try {
      if (maxView > -1) {
        Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + this.databaseName + "String_Node_Str"+ databaseDir+ File.separator+ "String_Node_Str"+ index+ "String_Node_Str"+ maxView+ "String_Node_Str"+ maxSeq);
        assert(comparators[index] != null);
        trees.set(index,new LSMTree(databaseDir + File.separator + getSnapshotFilename(index,maxView,maxSeq),comparators[index],this.compression,this.maxEntriesPerBlock,this.maxBlockFileSize,!this.disableMMap,this.mmapLimit));
        ondiskLSN=new LSN(maxView,maxSeq);
      }
 else {
        ondiskLSN=NO_DB_LSN;
        Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + this.databaseName);
        assert(comparators[index] != null);
        trees.set(index,new LSMTree(null,comparators[index],this.compression,this.maxEntriesPerBlock,this.maxBlockFileSize,!this.disableMMap,this.mmapLimit));
      }
    }
 catch (    IOException ex) {
      Logging.logError(Logging.LEVEL_ERROR,this,ex);
      throw new BabuDBException(ErrorCode.IO_ERROR,"String_Node_Str",ex);
    }
  }
}

Fixed version (ground truth):
/** 
 * Load the most recent snapshots of each tree.
 * @param numIndices the number of indices to read.
 * @throws java.io.IOException if the on-disk data cannot be read
 */
private void loadFromDisk(int numIndices) throws BabuDBException {
  Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + this.databaseName + "String_Node_Str");
  for (int index=0; index < numIndices; index++) {
    trees.add(null);
  }
  for (int index=0; index < numIndices; index++) {
    final int idx=index;
    File f=new File(databaseDir);
    String[] files=f.list(new FilenameFilter(){
      public boolean accept(      File dir,      String name){
        return name.startsWith("String_Node_Str" + idx + "String_Node_Str");
      }
    }
);
    if (files == null)     throw new BabuDBException(ErrorCode.IO_ERROR,"String_Node_Str" + databaseDir + "String_Node_Str");
    int maxView=-1;
    long maxSeq=-1;
    Pattern p=Pattern.compile(SNAPSHOT_FILENAME_REGEXP);
    for (    String fname : files) {
      Matcher m=p.matcher(fname);
      m.matches();
      Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + fname);
      int view=Integer.valueOf(m.group(2));
      long seq=Long.valueOf(m.group(3));
      if (view > maxView) {
        maxView=view;
        maxSeq=seq;
      }
 else       if (view == maxView) {
        if (seq > maxSeq)         maxSeq=seq;
      }
    }
    try {
      if (maxView > -1) {
        Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + this.databaseName + "String_Node_Str"+ databaseDir+ File.separator+ "String_Node_Str"+ index+ "String_Node_Str"+ maxView+ "String_Node_Str"+ maxSeq);
        assert(comparators[index] != null);
        trees.set(index,new LSMTree(databaseDir + File.separator + getSnapshotFilename(index,maxView,maxSeq),comparators[index],this.compression,this.maxEntriesPerBlock,this.maxBlockFileSize,!this.disableMMap,this.mmapLimit));
        ondiskLSN=new LSN(maxView,maxSeq);
      }
 else {
        ondiskLSN=NO_DB_LSN;
        Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + this.databaseName);
        assert(comparators[index] != null);
        trees.set(index,new LSMTree(null,comparators[index],this.compression,this.maxEntriesPerBlock,this.maxBlockFileSize,!this.disableMMap,this.mmapLimit));
      }
    }
 catch (    IOException ex) {
      Logging.logError(Logging.LEVEL_ERROR,this,ex);
      throw new BabuDBException(ErrorCode.IO_ERROR,"String_Node_Str",ex);
    }
  }
}