diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALFactory.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALFactory.java index e1a16254224..3500bd0ff88 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALFactory.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALFactory.java @@ -187,7 +187,11 @@ public class WALFactory { if (null != metaProvider) { metaProvider.close(); } - provider.close(); + // close is called on a WALFactory with null provider in the case of contention handling + // within the getInstance method. + if (null != provider) { + provider.close(); + } } /** diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/TestWALFactory.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/TestWALFactory.java index b5fd6f41ed9..47b001aa73d 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/TestWALFactory.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/TestWALFactory.java @@ -152,6 +152,11 @@ public class TestWALFactory { TEST_UTIL.shutdownMiniCluster(); } + @Test + public void canCloseSingleton() throws IOException { + WALFactory.getInstance(conf).close(); + } + /** * Just write multiple logs then split. Before fix for HADOOP-2283, this * would fail.