diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java index f72126fbe07..69db63c073d 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java @@ -256,7 +256,7 @@ public class TestHRegion { assertEquals(HConstants.NO_SEQNUM, region.getMaxFlushedSeqId()); // Weird. This returns 0 if no store files or no edits. Afraid to change it. assertEquals(0, (long)region.getMaxStoreSeqId().get(COLUMN_FAMILY_BYTES)); - region.close(); + HBaseTestingUtility.closeRegionAndWAL(this.region); assertEquals(HConstants.NO_SEQNUM, region.getMaxFlushedSeqId()); assertEquals(0, (long)region.getMaxStoreSeqId().get(COLUMN_FAMILY_BYTES)); // Open region again. @@ -271,7 +271,9 @@ public class TestHRegion { assertEquals(0, (long)region.getMaxStoreSeqId().get(COLUMN_FAMILY_BYTES)); region.flush(true); long max = region.getMaxFlushedSeqId(); + HBaseTestingUtility.closeRegionAndWAL(this.region); assertEquals(max, region.getMaxFlushedSeqId()); + this.region = null; } /** @@ -301,8 +303,9 @@ public class TestHRegion { put.add(COLUMN_FAMILY_BYTES, Bytes.toBytes("abc"), value); region.put(put); // Close with something in memstore and something in the snapshot. Make sure all is cleared. - region.close(); + HBaseTestingUtility.closeRegionAndWAL(region); assertEquals(0, region.getMemstoreSize()); + region = null; } /* @@ -561,7 +564,8 @@ public class TestHRegion { p2.add(new KeyValue(row, COLUMN_FAMILY_BYTES, qual3, 3, (byte[])null)); region.put(p2); // Now try close on top of a failing flush. - region.close(); + HBaseTestingUtility.closeRegionAndWAL(region); + region = null; fail(); } catch (IOException dse) { // Expected @@ -943,7 +947,7 @@ public class TestHRegion { // close the region now, and reopen again region.getTableDesc(); region.getRegionInfo(); - region.close(); + HBaseTestingUtility.closeRegionAndWAL(this.region); try { region = HRegion.openHRegion(region, null); } catch (WrongRegionException wre) { @@ -1074,9 +1078,8 @@ public class TestHRegion { } } - // close the region now, and reopen again - region.close(); + HBaseTestingUtility.closeRegionAndWAL(this.region); region = HRegion.openHRegion(region, null); // now check whether we have can read back the data from region @@ -1087,7 +1090,7 @@ public class TestHRegion { assertArrayEquals(Bytes.toBytes(i), value); } } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; wals.close(); } @@ -1275,7 +1278,8 @@ public class TestHRegion { } } finally { if (this.region != null) { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); + this.region = null; } } done.set(true); @@ -1577,6 +1581,7 @@ public class TestHRegion { Thread.sleep(10); startingClose.countDown(); HBaseTestingUtility.closeRegionAndWAL(region); + region = null; } catch (IOException e) { throw new RuntimeException(e); } catch (InterruptedException e) { @@ -4333,6 +4338,8 @@ public class TestHRegion { // Verify that the .regioninfo file is still there assertTrue(HRegionFileSystem.REGION_INFO_FILE + " should be present in the region dir", fs.exists(new Path(regionDir, HRegionFileSystem.REGION_INFO_FILE))); + + region = null; } /** @@ -5781,7 +5788,7 @@ public class TestHRegion { // create a file in fam1 for the region before opening in OpenRegionHandler region.put(new Put(Bytes.toBytes("a")).add(fam1, fam1, fam1)); region.flush(true); - region.close(); + HBaseTestingUtility.closeRegionAndWAL(region); ArgumentCaptor editCaptor = ArgumentCaptor.forClass(WALEdit.class);