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 322a1e4b5a2e..d244ca767be2 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 @@ -287,21 +287,26 @@ public void testSequenceId() throws IOException { HBaseTestingUtil.closeRegionAndWAL(this.region); assertEquals(HConstants.NO_SEQNUM, region.getMaxFlushedSeqId()); assertEquals(0, (long) region.getMaxStoreSeqId().get(COLUMN_FAMILY_BYTES)); - // Open region again. - region = initHRegion(tableName, method, CONF, COLUMN_FAMILY_BYTES); - byte[] value = Bytes.toBytes(method); - // Make a random put against our cf. - Put put = new Put(value); - put.addColumn(COLUMN_FAMILY_BYTES, null, value); - region.put(put); - // No flush yet so init numbers should still be in place. - assertEquals(HConstants.NO_SEQNUM, region.getMaxFlushedSeqId()); - assertEquals(0, (long) region.getMaxStoreSeqId().get(COLUMN_FAMILY_BYTES)); - region.flush(true); - long max = region.getMaxFlushedSeqId(); - HBaseTestingUtil.closeRegionAndWAL(this.region); - assertEquals(max, region.getMaxFlushedSeqId()); - this.region = null; + HRegion oldRegion = region; + try { + // Open region again. + region = initHRegion(tableName, method, CONF, COLUMN_FAMILY_BYTES); + byte[] value = Bytes.toBytes(method); + // Make a random put against our cf. + Put put = new Put(value); + put.addColumn(COLUMN_FAMILY_BYTES, null, value); + region.put(put); + // No flush yet so init numbers should still be in place. + assertEquals(HConstants.NO_SEQNUM, region.getMaxFlushedSeqId()); + assertEquals(0, (long) region.getMaxStoreSeqId().get(COLUMN_FAMILY_BYTES)); + region.flush(true); + long max = region.getMaxFlushedSeqId(); + HBaseTestingUtil.closeRegionAndWAL(this.region); + assertEquals(max, region.getMaxFlushedSeqId()); + this.region = null; + } finally { + HBaseTestingUtil.closeRegionAndWAL(oldRegion); + } } /** @@ -7608,7 +7613,7 @@ public void run() { holder.start(); latch.await(); - region.close(); + HBaseTestingUtil.closeRegionAndWAL(region); region = null; holder.join();