private void writeCorruptRecoveredHFile(Path recoveredHFile) throws Exception {
    // Read the recovered hfile
    int fileSize = (int) fs.listStatus(recoveredHFile)[0].getLen();
    FSDataInputStream in = fs.open(recoveredHFile);
    byte[] fileContent = new byte[fileSize];
    in.readFully(0, fileContent, 0, fileSize);
    in.close();

    // Write a corrupt hfile by append garbage
    Path path = new Path(recoveredHFile.getParent(), recoveredHFile.getName() + ".corrupt");
    FSDataOutputStream out;
    out = fs.create(path);
    out.write(fileContent);
    out.write(Bytes.toBytes("-----"));
    out.close();
  }
Test that we could recover the data correctly after aborting flush. In the test, first we abort
flush after writing some data, then writing more data and flush again, at last verify the data.
hbase-server/src/test/java/org/apache/hadoop/hbase/wal/TestWALSplitToHFile.java