@Test
  public void testContendedLogRolling() throws Exception {
    TEST_UTIL.startMiniDFSCluster(3);
    Path dir = TEST_UTIL.getDataTestDirOnTestFS();

    // The implementation needs to know the 'handler' count.
    TEST_UTIL.getConfiguration().setInt(HConstants.REGION_SERVER_HANDLER_COUNT, NUM_THREADS);
    final Configuration conf = new Configuration(TEST_UTIL.getConfiguration());
    conf.set(WALFactory.WAL_PROVIDER, "filesystem");
    CommonFSUtils.setRootDir(conf, dir);
    FSTableDescriptors fsTableDescriptors = new FSTableDescriptors(TEST_UTIL.getConfiguration());
    FSTableDescriptors.tryUpdateMetaTableDescriptor(TEST_UTIL.getConfiguration());
    TableDescriptor metaTableDescriptor = fsTableDescriptors.get(TableName.META_TABLE_NAME);
    conf.set(FSHLogProvider.WRITER_IMPL, HighLatencySyncWriter.class.getName());
    final WALFactory wals = new WALFactory(conf, TestLogRollingNoCluster.class.getName());
    final WAL wal = wals.getWAL(null);

    Appender[] appenders = null;

    final int numThreads = NUM_THREADS;
    appenders = new Appender[numThreads];
    try {
      for (int i = 0; i < numThreads; i++) {
        // Have each appending thread write 'count' entries
        appenders[i] = new Appender(metaTableDescriptor, wal, i, NUM_ENTRIES);
      }
      for (int i = 0; i < numThreads; i++) {
        appenders[i].start();
      }
      for (int i = 0; i < numThreads; i++) {
        // ensure that all threads are joined before closing the wal
        appenders[i].join();
      }
    } finally {
      wals.close();
    }
    for (int i = 0; i < numThreads; i++) {
      assertFalse("Error: " + appenders[i].getException(), appenders[i].isException());
    }
    TEST_UTIL.shutdownMiniDFSCluster();
  }
Spin up a bunch of threads and have them all append to a WAL. Roll the WAL frequently to try
and trigger NPE.
hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestLogRollingNoCluster.java