Program: 15891
Project: 15891
Buggy source:
/** 
 * Read the contents of the file and display them in a human-readable format.
 * @param fileName the name of the file
 * @param writer the print writer
 */
public static void dump(String fileName,Writer writer){
  PrintWriter pw=new PrintWriter(writer,true);
  if (!FilePath.get(fileName).exists()) {
    pw.println("String_Node_Str" + fileName);
    return;
  }
  FileChannel file=null;
  int blockSize=MVStore.BLOCK_SIZE;
  try {
    file=FilePath.get(fileName).open("String_Node_Str");
    long fileLength=file.size();
    pw.println("String_Node_Str" + fileName);
    pw.println("String_Node_Str" + fileLength);
    ByteBuffer block=ByteBuffer.allocate(4096);
    for (long pos=0; pos < fileLength; ) {
      block.rewind();
      DataUtils.readFully(file,pos,block);
      block.rewind();
      int tag=block.get();
      if (tag == 'H') {
        pw.println("String_Node_Str" + pos);
        pw.println("String_Node_Str" + new String(block.array(),"String_Node_Str").trim());
        pos+=blockSize;
        continue;
      }
      if (tag != 'c') {
        pos+=blockSize;
        continue;
      }
      int chunkLength=block.getInt();
      int chunkId=block.getInt();
      int pageCount=block.getInt();
      long metaRootPos=block.getLong();
      long maxLength=block.getLong();
      long maxLengthLive=block.getLong();
      pw.println("String_Node_Str" + chunkId + "String_Node_Str"+ pos+ "String_Node_Str"+ chunkLength+ "String_Node_Str"+ pageCount+ "String_Node_Str"+ metaRootPos+ "String_Node_Str"+ DataUtils.getPageChunkId(metaRootPos)+ "String_Node_Str"+ DataUtils.getPageOffset(metaRootPos)+ "String_Node_Str"+ maxLength+ "String_Node_Str"+ maxLengthLive);
      ByteBuffer chunk=ByteBuffer.allocate(chunkLength);
      DataUtils.readFully(file,pos,chunk);
      int p=block.position();
      pos=(pos + chunkLength + blockSize) / blockSize * blockSize;
      chunkLength-=p;
      while (chunkLength > 0) {
        chunk.position(p);
        int pageLength=chunk.getInt();
        chunk.getShort();
        long mapId=DataUtils.readVarInt(chunk);
        int len=DataUtils.readVarInt(chunk);
        int type=chunk.get();
        boolean compressed=(type & 2) != 0;
        boolean node=(type & 1) != 0;
        pw.println("String_Node_Str" + mapId + "String_Node_Str"+ p+ "String_Node_Str"+ (node ? "String_Node_Str" : "String_Node_Str")+ "String_Node_Str"+ (compressed ? "String_Node_Str" : "String_Node_Str")+ "String_Node_Str"+ pageLength+ "String_Node_Str"+ len);
        p+=pageLength;
        chunkLength-=pageLength;
      }
    }
  }
 catch (  IOException e) {
    pw.println("String_Node_Str" + e);
    e.printStackTrace(pw);
  }
 finally {
    if (file != null) {
      try {
        file.close();
      }
 catch (      IOException e) {
      }
    }
  }
  pw.println();
  pw.flush();
}

Fixed version (ground truth):
/** 
 * Read the contents of the file and display them in a human-readable format.
 * @param fileName the name of the file
 * @param writer the print writer
 */
public static void dump(String fileName,Writer writer){
  PrintWriter pw=new PrintWriter(writer,true);
  if (!FilePath.get(fileName).exists()) {
    pw.println("String_Node_Str" + fileName);
    return;
  }
  FileChannel file=null;
  int blockSize=MVStore.BLOCK_SIZE;
  try {
    file=FilePath.get(fileName).open("String_Node_Str");
    long fileLength=file.size();
    pw.println("String_Node_Str" + fileName);
    pw.println("String_Node_Str" + fileLength);
    ByteBuffer block=ByteBuffer.allocate(4096);
    for (long pos=0; pos < fileLength; ) {
      block.rewind();
      DataUtils.readFully(file,pos,block);
      block.rewind();
      int tag=block.get();
      if (tag == 'H') {
        pw.println("String_Node_Str" + pos);
        pw.println("String_Node_Str" + new String(block.array(),"String_Node_Str").trim());
        pos+=blockSize;
        continue;
      }
      if (tag != 'c') {
        pos+=blockSize;
        continue;
      }
      int chunkLength=block.getInt();
      int chunkId=block.getInt();
      int pageCount=block.getInt();
      long metaRootPos=block.getLong();
      long maxLength=block.getLong();
      long maxLengthLive=block.getLong();
      pw.println("String_Node_Str" + chunkId + "String_Node_Str"+ pos+ "String_Node_Str"+ chunkLength+ "String_Node_Str"+ pageCount+ "String_Node_Str"+ getPosString(metaRootPos)+ "String_Node_Str"+ maxLength+ "String_Node_Str"+ maxLengthLive);
      ByteBuffer chunk=ByteBuffer.allocate(chunkLength);
      DataUtils.readFully(file,pos,chunk);
      int p=block.position();
      pos=(pos + chunkLength + blockSize) / blockSize * blockSize;
      chunkLength-=p;
      while (chunkLength > 0) {
        chunk.position(p);
        int pageLength=chunk.getInt();
        chunk.getShort();
        long mapId=DataUtils.readVarInt(chunk);
        int len=DataUtils.readVarInt(chunk);
        int type=chunk.get();
        boolean compressed=(type & 2) != 0;
        boolean node=(type & 1) != 0;
        pw.println("String_Node_Str" + mapId + "String_Node_Str"+ p+ "String_Node_Str"+ (node ? "String_Node_Str" : "String_Node_Str")+ "String_Node_Str"+ (compressed ? "String_Node_Str" : "String_Node_Str")+ "String_Node_Str"+ pageLength+ "String_Node_Str"+ len);
        p+=pageLength;
        chunkLength-=pageLength;
        if (mapId == 0 && !compressed) {
          String[] keys=new String[len];
          for (int i=0; i < len; i++) {
            String k=StringDataType.INSTANCE.read(chunk);
            keys[i]=k;
          }
          if (node) {
            long[] children=new long[len + 1];
            for (int i=0; i <= len; i++) {
              children[i]=chunk.getLong();
            }
            long[] counts=new long[len + 1];
            for (int i=0; i <= len; i++) {
              long s=DataUtils.readVarLong(chunk);
              counts[i]=s;
            }
            for (int i=0; i < len; i++) {
              pw.println("String_Node_Str" + keys[i] + "String_Node_Str"+ counts[i]+ "String_Node_Str"+ getPosString(children[i]));
            }
            pw.println("String_Node_Str" + counts[len] + "String_Node_Str"+ getPosString(children[len]));
          }
 else {
            String[] values=new String[len];
            for (int i=0; i < len; i++) {
              String v=StringDataType.INSTANCE.read(chunk);
              values[i]=v;
            }
            for (int i=0; i < len; i++) {
              pw.println("String_Node_Str" + keys[i] + "String_Node_Str"+ values[i]);
            }
          }
        }
      }
    }
  }
 catch (  IOException e) {
    pw.println("String_Node_Str" + e);
    e.printStackTrace(pw);
  }
 finally {
    if (file != null) {
      try {
        file.close();
      }
 catch (      IOException e) {
      }
    }
  }
  pw.println();
  pw.flush();
}