You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by te...@apache.org on 2015/01/06 00:46:03 UTC

[1/2] hbase git commit: HBASE-12802 Remove unnecessary Table.flushCommits() (Solomon Duskis)

Repository: hbase
Updated Branches:
  refs/heads/master 5b53a187d -> 2452d3861


http://git-wip-us.apache.org/repos/asf/hbase/blob/2452d386/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsWithDeletes.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsWithDeletes.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsWithDeletes.java
index 5b718f0..6029c8b 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsWithDeletes.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsWithDeletes.java
@@ -25,6 +25,7 @@ import java.io.IOException;
 import java.io.InterruptedIOException;
 import java.security.PrivilegedExceptionAction;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 import org.apache.hadoop.conf.Configuration;
@@ -118,17 +119,13 @@ public class TestVisibilityLabelsWithDeletes {
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          Table table = null;
-          try {
-            table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility(TOPSECRET + "&" + SECRET));
-            d.deleteColumns(fam, qual);
+            d.addColumns(fam, qual);
             table.delete(d);
           } catch (Throwable t) {
             throw new IOException(t);
-          } finally {
-            table.close();
           }
           return null;
         }
@@ -164,11 +161,10 @@ public class TestVisibilityLabelsWithDeletes {
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row2);
             d.setCellVisibility(new CellVisibility(TOPSECRET + "|" + CONFIDENTIAL));
-            d.deleteFamily(fam);
+            d.addFamily(fam);
             table.delete(d);
           } catch (Throwable t) {
             throw new IOException(t);
@@ -207,17 +203,13 @@ public class TestVisibilityLabelsWithDeletes {
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          Table table = null;
-          try {
-            table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility(TOPSECRET + "|" + CONFIDENTIAL));
             d.deleteFamilyVersion(fam, 123l);
             table.delete(d);
           } catch (Throwable t) {
             throw new IOException(t);
-          } finally {
-            table.close();
           }
           return null;
         }
@@ -253,17 +245,13 @@ public class TestVisibilityLabelsWithDeletes {
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          Table table = null;
-          try {
-            table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility(TOPSECRET + "|" + CONFIDENTIAL));
-            d.deleteColumn(fam, qual, 123l);
+            d.addColumn(fam, qual, 123l);
             table.delete(d);
           } catch (Throwable t) {
             throw new IOException(t);
-          } finally {
-            table.close();
           }
           return null;
         }
@@ -292,19 +280,16 @@ public class TestVisibilityLabelsWithDeletes {
   public void testVisibilityLabelsWithDeleteColumnsWithMultipleVersions() throws Exception {
     setAuths();
     final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
-    Table table = null;
-    try {
-      table = doPuts(tableName);
+    try (Table table = doPuts(tableName)) {
       TEST_UTIL.getHBaseAdmin().flush(tableName);
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility("(" + PRIVATE + "&" + CONFIDENTIAL + ")|(" +
                 SECRET + "&" + TOPSECRET+")"));
-            d.deleteColumns(fam, qual, 125l);
+            d.addColumns(fam, qual, 125l);
             table.delete(d);
           } catch (Throwable t) {
             throw new IOException(t);
@@ -342,10 +327,6 @@ public class TestVisibilityLabelsWithDeletes {
       current = cellScanner.current();
       assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
           current.getRowLength(), row2, 0, row2.length));
-    } finally {
-      if (table != null) {
-        table.close();
-      }
     }
   }
 
@@ -354,32 +335,28 @@ public class TestVisibilityLabelsWithDeletes {
       throws Exception {
     setAuths();
     final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
-    Table table = null;
-    try {
-      table = doPuts(tableName);
+    try (Table table = doPuts(tableName)) {
       TEST_UTIL.getHBaseAdmin().flush(tableName);
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
-            Delete d = new Delete(row1);
-            d.setCellVisibility(new CellVisibility(CONFIDENTIAL));
-            d.deleteColumns(fam, qual);
-            table.delete(d);
+          try (Table table = new HTable(conf, tableName)) {
+            Delete d1 = new Delete(row1);
+            d1.setCellVisibility(new CellVisibility(CONFIDENTIAL));
+            d1.addColumns(fam, qual);
 
-            d = new Delete(row1);
-            d.setCellVisibility(new CellVisibility(SECRET + "&" + TOPSECRET));
-            d.deleteColumns(fam, qual);
-            table.delete(d);
-            table.flushCommits();
+            table.delete(d1);
 
-            d = new Delete(row1);
-            d.setCellVisibility(new CellVisibility("(" + PRIVATE + "&" + CONFIDENTIAL + ")|("
+            Delete d2 = new Delete(row1);
+            d2.setCellVisibility(new CellVisibility(SECRET + "&" + TOPSECRET));
+            d2.addColumns(fam, qual);
+            table.delete(d2);
+
+            Delete d3 = new Delete(row1);
+            d3.setCellVisibility(new CellVisibility("(" + PRIVATE + "&" + CONFIDENTIAL + ")|("
                 + SECRET + "&" + TOPSECRET + ")"));
-            d.deleteColumns(fam, qual);
-            table.delete(d);
-            table.flushCommits();
+            d3.addColumns(fam, qual);
+            table.delete(d3);
           } catch (Throwable t) {
             throw new IOException(t);
           }
@@ -392,16 +369,12 @@ public class TestVisibilityLabelsWithDeletes {
       s.setAuthorizations(new Authorizations(SECRET, PRIVATE, CONFIDENTIAL, TOPSECRET));
       ResultScanner scanner = table.getScanner(s);
       Result[] next = scanner.next(3);
-      assertTrue(next.length == 1);
+      assertEquals(1, next.length);
       CellScanner cellScanner = next[0].cellScanner();
       cellScanner.advance();
       Cell current = cellScanner.current();
       assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
           current.getRowLength(), row2, 0, row2.length));
-    } finally {
-      if (table != null) {
-        table.close();
-      }
     }
   }
 
@@ -411,32 +384,27 @@ public class TestVisibilityLabelsWithDeletes {
       throws Exception {
     setAuths();
     final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
-    Table table = null;
-    try {
-      table = doPuts(tableName);
+    try (Table table = doPuts(tableName)) {
       TEST_UTIL.getHBaseAdmin().flush(tableName);
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility(CONFIDENTIAL));
-            d.deleteColumns(fam, qual);
+            d.addColumns(fam, qual);
             table.delete(d);
 
             d = new Delete(row1);
             d.setCellVisibility(new CellVisibility(SECRET));
-            d.deleteColumns(fam, qual);
+            d.addColumns(fam, qual);
             table.delete(d);
-            table.flushCommits();
 
             d = new Delete(row1);
             d.setCellVisibility(new CellVisibility("(" + PRIVATE + "&" + CONFIDENTIAL + ")|("
                 + SECRET + "&" + TOPSECRET + ")"));
-            d.deleteColumns(fam, qual);
+            d.addColumns(fam, qual);
             table.delete(d);
-            table.flushCommits();
           } catch (Throwable t) {
             throw new IOException(t);
           }
@@ -460,10 +428,6 @@ public class TestVisibilityLabelsWithDeletes {
       current = cellScanner.current();
       assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
           current.getRowLength(), row2, 0, row2.length));
-    } finally {
-      if (table != null) {
-        table.close();
-      }
     }
   }
 
@@ -472,32 +436,27 @@ public class TestVisibilityLabelsWithDeletes {
       throws Exception {
     setAuths();
     final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
-    Table table = null;
-    try {
-      table = doPuts(tableName);
+    try (Table table = doPuts(tableName)) {
       TEST_UTIL.getHBaseAdmin().flush(tableName);
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
-            Delete d = new Delete(row1);
-            d.setCellVisibility(new CellVisibility(CONFIDENTIAL));
-            d.deleteFamily(fam);
-            table.delete(d);
-
-            d = new Delete(row1);
-            d.setCellVisibility(new CellVisibility(SECRET + "&" + TOPSECRET));
-            d.deleteFamily(fam);
-            table.delete(d);
-            table.flushCommits();
-
-            d = new Delete(row1);
-            d.setCellVisibility(new CellVisibility("(" + PRIVATE + "&" + CONFIDENTIAL + ")|("
+          try (Table table = new HTable(conf, tableName)) {
+            Delete d1 = new Delete(row1);
+            d1.setCellVisibility(new CellVisibility(CONFIDENTIAL));
+            d1.addFamily(fam);
+            table.delete(d1);
+
+            Delete d2 = new Delete(row1);
+            d2.setCellVisibility(new CellVisibility(SECRET + "&" + TOPSECRET));
+            d2.addFamily(fam);
+            table.delete(d2);
+
+            Delete d3 = new Delete(row1);
+            d3.setCellVisibility(new CellVisibility("(" + PRIVATE + "&" + CONFIDENTIAL + ")|("
                 + SECRET + "&" + TOPSECRET + ")"));
-            d.deleteFamily(fam);
-            table.delete(d);
-            table.flushCommits();
+            d3.addFamily(fam);
+            table.delete(d3);
           } catch (Throwable t) {
             throw new IOException(t);
           }
@@ -510,31 +469,25 @@ public class TestVisibilityLabelsWithDeletes {
       s.setAuthorizations(new Authorizations(SECRET, PRIVATE, CONFIDENTIAL, TOPSECRET));
       ResultScanner scanner = table.getScanner(s);
       Result[] next = scanner.next(3);
-      assertTrue(next.length == 1);
+      assertEquals(1, next.length);
       CellScanner cellScanner = next[0].cellScanner();
       cellScanner.advance();
       Cell current = cellScanner.current();
       assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
           current.getRowLength(), row2, 0, row2.length));
-    } finally {
-      if (table != null) {
-        table.close();
-      }
     }
   }
 
   @Test
   public void testVisibilityLabelsWithDeleteFamilyWithPutsReAppearing() throws Exception {
     final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
-    Table table = null;
-    try {
-      Admin hBaseAdmin = TEST_UTIL.getHBaseAdmin();
-      HColumnDescriptor colDesc = new HColumnDescriptor(fam);
-      colDesc.setMaxVersions(5);
-      HTableDescriptor desc = new HTableDescriptor(tableName);
-      desc.addFamily(colDesc);
-      hBaseAdmin.createTable(desc);
-      table = new HTable(conf, tableName);
+    Admin hBaseAdmin = TEST_UTIL.getHBaseAdmin();
+    HColumnDescriptor colDesc = new HColumnDescriptor(fam);
+    colDesc.setMaxVersions(5);
+    HTableDescriptor desc = new HTableDescriptor(tableName);
+    desc.addFamily(colDesc);
+    hBaseAdmin.createTable(desc);
+    try (Table table = new HTable(conf, tableName)) {
       Put put = new Put(Bytes.toBytes("row1"));
       put.add(fam, qual, value);
       put.setCellVisibility(new CellVisibility(CONFIDENTIAL));
@@ -547,13 +500,11 @@ public class TestVisibilityLabelsWithDeletes {
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility(CONFIDENTIAL));
-            d.deleteFamily(fam);
+            d.addFamily(fam);
             table.delete(d);
-            table.flushCommits();
           } catch (Throwable t) {
             throw new IOException(t);
           }
@@ -574,13 +525,11 @@ public class TestVisibilityLabelsWithDeletes {
       actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility(SECRET));
-            d.deleteFamily(fam);
+            d.addFamily(fam);
             table.delete(d);
-            table.flushCommits();
           } catch (Throwable t) {
             throw new IOException(t);
           }
@@ -600,25 +549,19 @@ public class TestVisibilityLabelsWithDeletes {
       scanner = table.getScanner(s);
       Result[] next1 = scanner.next(3);
       assertEquals(next1.length, 0);
-    } finally {
-      if (table != null) {
-        table.close();
-      }
     }
   }
 
   @Test
   public void testVisibilityLabelsWithDeleteColumnsWithPutsReAppearing() throws Exception {
     final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
-    Table table = null;
-    try {
-      Admin hBaseAdmin = TEST_UTIL.getHBaseAdmin();
-      HColumnDescriptor colDesc = new HColumnDescriptor(fam);
-      colDesc.setMaxVersions(5);
-      HTableDescriptor desc = new HTableDescriptor(tableName);
-      desc.addFamily(colDesc);
-      hBaseAdmin.createTable(desc);
-      table = new HTable(conf, tableName);
+    Admin hBaseAdmin = TEST_UTIL.getHBaseAdmin();
+    HColumnDescriptor colDesc = new HColumnDescriptor(fam);
+    colDesc.setMaxVersions(5);
+    HTableDescriptor desc = new HTableDescriptor(tableName);
+    desc.addFamily(colDesc);
+    hBaseAdmin.createTable(desc);
+    try (Table table = new HTable(conf, tableName)) {
       Put put = new Put(Bytes.toBytes("row1"));
       put.add(fam, qual, value);
       put.setCellVisibility(new CellVisibility(CONFIDENTIAL));
@@ -631,13 +574,11 @@ public class TestVisibilityLabelsWithDeletes {
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility(CONFIDENTIAL));
-            d.deleteColumns(fam, qual);
+            d.addColumns(fam, qual);
             table.delete(d);
-            table.flushCommits();
           } catch (Throwable t) {
             throw new IOException(t);
           }
@@ -658,13 +599,11 @@ public class TestVisibilityLabelsWithDeletes {
       actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility(SECRET));
-            d.deleteColumns(fam, qual);
+            d.addColumns(fam, qual);
             table.delete(d);
-            table.flushCommits();
           } catch (Throwable t) {
             throw new IOException(t);
           }
@@ -684,25 +623,19 @@ public class TestVisibilityLabelsWithDeletes {
       scanner = table.getScanner(s);
       Result[] next1 = scanner.next(3);
       assertEquals(next1.length, 0);
-    } finally {
-      if (table != null) {
-        table.close();
-      }
     }
   }
 
   @Test
   public void testVisibilityCombinations() throws Exception {
     final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
-    Table table = null;
-    try {
-      Admin hBaseAdmin = TEST_UTIL.getHBaseAdmin();
-      HColumnDescriptor colDesc = new HColumnDescriptor(fam);
-      colDesc.setMaxVersions(5);
-      HTableDescriptor desc = new HTableDescriptor(tableName);
-      desc.addFamily(colDesc);
-      hBaseAdmin.createTable(desc);
-      table = new HTable(conf, tableName);
+    Admin hBaseAdmin = TEST_UTIL.getHBaseAdmin();
+    HColumnDescriptor colDesc = new HColumnDescriptor(fam);
+    colDesc.setMaxVersions(5);
+    HTableDescriptor desc = new HTableDescriptor(tableName);
+    desc.addFamily(colDesc);
+    hBaseAdmin.createTable(desc);
+    try (Table table = new HTable(conf, tableName)) {
       Put put = new Put(Bytes.toBytes("row1"));
       put.add(fam, qual, 123l, value);
       put.setCellVisibility(new CellVisibility(CONFIDENTIAL));
@@ -711,23 +644,23 @@ public class TestVisibilityLabelsWithDeletes {
       put.add(fam, qual, 124l, value1);
       put.setCellVisibility(new CellVisibility(SECRET));
       table.put(put);
-      table.flushCommits();
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility(SECRET));
-            d.deleteColumns(fam, qual, 126l);
+            d.addColumns(fam, qual, 126l);
             table.delete(d);
+          } catch (Throwable t) {
+            throw new IOException(t);
+          }
 
-            table = new HTable(conf, tableName);
-            d = new Delete(row1);
+          try (Table table = new HTable(conf, tableName)) {
+            Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility(CONFIDENTIAL));
-            d.deleteColumn(fam, qual, 123l);
+            d.addColumn(fam, qual, 123l);
             table.delete(d);
-            table.flushCommits();
           } catch (Throwable t) {
             throw new IOException(t);
           }
@@ -741,57 +674,52 @@ public class TestVisibilityLabelsWithDeletes {
       ResultScanner scanner = table.getScanner(s);
       Result[] next = scanner.next(3);
       assertEquals(next.length, 0);
-    } finally {
-      if (table != null) {
-        table.close();
-      }
     }
   }
   @Test
   public void testVisibilityLabelsWithDeleteColumnWithSpecificVersionWithPutsReAppearing()
       throws Exception {
     final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
-    Table table = null;
-    try {
-      Admin hBaseAdmin = TEST_UTIL.getHBaseAdmin();
-      HColumnDescriptor colDesc = new HColumnDescriptor(fam);
-      colDesc.setMaxVersions(5);
-      HTableDescriptor desc = new HTableDescriptor(tableName);
-      desc.addFamily(colDesc);
-      hBaseAdmin.createTable(desc);
-      table = new HTable(conf, tableName);
-      Put put = new Put(Bytes.toBytes("row1"));
-      put.add(fam, qual, 123l, value);
-      put.setCellVisibility(new CellVisibility(CONFIDENTIAL));
-      table.put(put);
-      put = new Put(Bytes.toBytes("row1"));
-      put.add(fam, qual, 123l, value1);
-      put.setCellVisibility(new CellVisibility(SECRET));
-      table.put(put);
-      table.flushCommits();
-      //TEST_UTIL.getHBaseAdmin().flush(tableName);
+    Admin hBaseAdmin = TEST_UTIL.getHBaseAdmin();
+    HColumnDescriptor colDesc = new HColumnDescriptor(fam);
+    colDesc.setMaxVersions(5);
+    HTableDescriptor desc = new HTableDescriptor(tableName);
+    desc.addFamily(colDesc);
+    hBaseAdmin.createTable(desc);
+
+    try (Table table = new HTable(conf, tableName)) {
+      Put put1 = new Put(Bytes.toBytes("row1"));
+      put1.add(fam, qual, 123l, value);
+      put1.setCellVisibility(new CellVisibility(CONFIDENTIAL));
+
+      Put put2 = new Put(Bytes.toBytes("row1"));
+      put2.add(fam, qual, 123l, value1);
+      put2.setCellVisibility(new CellVisibility(SECRET));
+      table.put(createList(put1, put2));
+
       Scan s = new Scan();
       s.setMaxVersions(5);
       s.setAuthorizations(new Authorizations(CONFIDENTIAL, SECRET));
+
       ResultScanner scanner = table.getScanner(s);
-      Result[] next = scanner.next(3);
-      assertEquals(next.length, 1);
+      assertEquals(scanner.next(3).length, 1);
+      scanner.close();
+
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility(CONFIDENTIAL));
-            d.deleteColumn(fam, qual, 123l);
+            d.addColumn(fam, qual, 123l);
             table.delete(d);
+          }
 
-            table = new HTable(conf, tableName);
-            d = new Delete(row1);
+          try (Table table = new HTable(conf, tableName)) {
+            Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility(SECRET));
-            d.deleteColumn(fam, qual, 123l);
+            d.addColumn(fam, qual, 123l);
             table.delete(d);
-            table.flushCommits();
           } catch (Throwable t) {
             throw new IOException(t);
           }
@@ -803,12 +731,8 @@ public class TestVisibilityLabelsWithDeletes {
       s.setMaxVersions(5);
       s.setAuthorizations(new Authorizations(CONFIDENTIAL));
       scanner = table.getScanner(s);
-      next = scanner.next(3);
-      assertEquals(next.length, 0);
-    } finally {
-      if (table != null) {
-        table.close();
-      }
+      assertEquals(scanner.next(3).length, 0);
+      scanner.close();
     }
   }
 
@@ -818,32 +742,26 @@ public class TestVisibilityLabelsWithDeletes {
       throws Exception {
     setAuths();
     final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
-    Table table = null;
-    try {
-      table = doPuts(tableName);
+    try (Table table = doPuts(tableName)) {
       TEST_UTIL.getHBaseAdmin().flush(tableName);
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
-            Delete d = new Delete(row1);
-            d.setCellVisibility(new CellVisibility(CONFIDENTIAL));
-            d.deleteFamily(fam);
-            table.delete(d);
+          Delete d1 = new Delete(row1);
+          d1.setCellVisibility(new CellVisibility(CONFIDENTIAL));
+          d1.addFamily(fam);
 
-            d = new Delete(row1);
-            d.setCellVisibility(new CellVisibility(SECRET));
-            d.deleteFamily(fam);
-            table.delete(d);
-            table.flushCommits();
+          Delete d2 = new Delete(row1);
+          d2.setCellVisibility(new CellVisibility(SECRET));
+          d2.addFamily(fam);
 
-            d = new Delete(row1);
-            d.setCellVisibility(new CellVisibility("(" + PRIVATE + "&" + CONFIDENTIAL + ")|("
-                + SECRET + "&" + TOPSECRET + ")"));
-            d.deleteFamily(fam);
-            table.delete(d);
-            table.flushCommits();
+          Delete d3 = new Delete(row1);
+          d3.setCellVisibility(new CellVisibility("(" + PRIVATE + "&" + CONFIDENTIAL + ")|("
+              + SECRET + "&" + TOPSECRET + ")"));
+          d3.addFamily(fam);
+
+          try (Table table = new HTable(conf, tableName)) {
+            table.delete(createList(d1, d2, d3));
           } catch (Throwable t) {
             throw new IOException(t);
           }
@@ -867,10 +785,7 @@ public class TestVisibilityLabelsWithDeletes {
       current = cellScanner.current();
       assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
           current.getRowLength(), row2, 0, row2.length));
-    } finally {
-      if (table != null) {
-        table.close();
-      }
+      scanner.close();
     }
   }
 
@@ -878,24 +793,19 @@ public class TestVisibilityLabelsWithDeletes {
   public void testDeleteFamilyAndDeleteColumnsWithAndWithoutVisibilityExp() throws Exception {
     setAuths();
     final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
-    Table table = null;
-    try {
-      table = doPuts(tableName);
+    try (Table table = doPuts(tableName)) {
       TEST_UTIL.getHBaseAdmin().flush(tableName);
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
-            Delete d = new Delete(row1);
-            d.deleteFamily(fam);
-            table.delete(d);
-
-            d = new Delete(row1);
-            d.setCellVisibility(new CellVisibility(SECRET + "&" + TOPSECRET));
-            d.deleteColumns(fam, qual);
-            table.delete(d);
-            table.flushCommits();
+          Delete d1 = new Delete(row1);
+          d1.addFamily(fam);
+
+          Delete d2 = new Delete(row1);
+          d2.setCellVisibility(new CellVisibility(SECRET + "&" + TOPSECRET));
+          d2.addColumns(fam, qual);
+          try (Table table = new HTable(conf, tableName)) {
+            table.delete(createList(d1, d2));
           } catch (Throwable t) {
             throw new IOException(t);
           }
@@ -935,119 +845,140 @@ public class TestVisibilityLabelsWithDeletes {
       current = cellScanner.current();
       assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
           current.getRowLength(), row2, 0, row2.length));
-    } finally {
-      if (table != null) {
-        table.close();
-      }
+      scanner.close();
     }
   }
 
   private Table doPuts(TableName tableName) throws IOException, InterruptedIOException,
       RetriesExhaustedWithDetailsException, InterruptedException {
-    Table table;
     Admin hBaseAdmin = TEST_UTIL.getHBaseAdmin();
     HColumnDescriptor colDesc = new HColumnDescriptor(fam);
     colDesc.setMaxVersions(5);
     HTableDescriptor desc = new HTableDescriptor(tableName);
     desc.addFamily(colDesc);
     hBaseAdmin.createTable(desc);
-    table = new HTable(conf, tableName);
+
+    List<Put> puts = new ArrayList<Put>();
     Put put = new Put(Bytes.toBytes("row1"));
     put.add(fam, qual, 123l, value);
     put.setCellVisibility(new CellVisibility(CONFIDENTIAL));
-    table.put(put);
+    puts.add(put);
+
     put = new Put(Bytes.toBytes("row1"));
     put.add(fam, qual, 124l, value);
     put.setCellVisibility(new CellVisibility("(" + CONFIDENTIAL + "&" + PRIVATE + ")|("
     + TOPSECRET + "&" + SECRET+")"));
-    table.put(put);
+    puts.add(put);
+
     put = new Put(Bytes.toBytes("row1"));
     put.add(fam, qual, 125l, value);
     put.setCellVisibility(new CellVisibility(SECRET + "&" + TOPSECRET));
-    table.put(put);
+    puts.add(put);
+
     put = new Put(Bytes.toBytes("row1"));
     put.add(fam, qual, 126l, value);
     put.setCellVisibility(new CellVisibility("(" + CONFIDENTIAL + "&" + PRIVATE + ")|("
         + TOPSECRET + "&" + SECRET+")"));
-    table.put(put);
+    puts.add(put);
+
     put = new Put(Bytes.toBytes("row1"));
     put.add(fam, qual, 127l, value);
     put.setCellVisibility(new CellVisibility("(" + CONFIDENTIAL + "&" + PRIVATE + ")|("
         + TOPSECRET + "&" + SECRET+")"));
-    table.put(put);
+    puts.add(put);
+
     TEST_UTIL.getHBaseAdmin().flush(tableName);
     put = new Put(Bytes.toBytes("row2"));
     put.add(fam, qual, 127l, value);
     put.setCellVisibility(new CellVisibility("(" + CONFIDENTIAL + "&" + PRIVATE + ")|(" + TOPSECRET
         + "&" + SECRET + ")"));
-    table.put(put);
+    puts.add(put);
+
+    Table table = new HTable(conf, tableName);
+    table.put(puts);
     return table;
   }
 
   private Table doPutsWithDiffCols(TableName tableName) throws IOException,
       InterruptedIOException, RetriesExhaustedWithDetailsException, InterruptedException {
-    Table table;
     Admin hBaseAdmin = TEST_UTIL.getHBaseAdmin();
     HColumnDescriptor colDesc = new HColumnDescriptor(fam);
     colDesc.setMaxVersions(5);
     HTableDescriptor desc = new HTableDescriptor(tableName);
     desc.addFamily(colDesc);
     hBaseAdmin.createTable(desc);
-    table = new HTable(conf, tableName);
+
+    List<Put> puts = new ArrayList<>();
     Put put = new Put(Bytes.toBytes("row1"));
     put.add(fam, qual, 123l, value);
     put.setCellVisibility(new CellVisibility(CONFIDENTIAL));
-    table.put(put);
+    puts.add(put);
+
     put = new Put(Bytes.toBytes("row1"));
     put.add(fam, qual, 124l, value);
     put.setCellVisibility(new CellVisibility("(" + CONFIDENTIAL + "&" + PRIVATE + ")|("
     + TOPSECRET + "&" + SECRET+")"));
-    table.put(put);
+    puts.add(put);
+
     put = new Put(Bytes.toBytes("row1"));
     put.add(fam, qual, 125l, value);
     put.setCellVisibility(new CellVisibility(SECRET + "&" + TOPSECRET));
-    table.put(put);
+    puts.add(put);
+
     put = new Put(Bytes.toBytes("row1"));
     put.add(fam, qual1, 126l, value);
     put.setCellVisibility(new CellVisibility(SECRET + "&" + TOPSECRET));
-    table.put(put);
+    puts.add(put);
+
     put = new Put(Bytes.toBytes("row1"));
     put.add(fam, qual2, 127l, value);
     put.setCellVisibility(new CellVisibility("(" + CONFIDENTIAL + "&" + PRIVATE + ")|("
         + TOPSECRET + "&" + SECRET+")"));
-    table.put(put);
+    puts.add(put);
+
+    Table table = new HTable(conf, tableName);
+    table.put(puts);
     return table;
   }
 
   private Table doPutsWithoutVisibility(TableName tableName) throws IOException,
       InterruptedIOException, RetriesExhaustedWithDetailsException, InterruptedException {
-    Table table;
     Admin hBaseAdmin = TEST_UTIL.getHBaseAdmin();
     HColumnDescriptor colDesc = new HColumnDescriptor(fam);
     colDesc.setMaxVersions(5);
     HTableDescriptor desc = new HTableDescriptor(tableName);
     desc.addFamily(colDesc);
     hBaseAdmin.createTable(desc);
-    table = new HTable(conf, tableName);
+    List<Put> puts = new ArrayList<>();
     Put put = new Put(Bytes.toBytes("row1"));
     put.add(fam, qual, 123l, value);
-    table.put(put);
+    puts.add(put);
+
     put = new Put(Bytes.toBytes("row1"));
     put.add(fam, qual, 124l, value);
-    table.put(put);
+    puts.add(put);
+
     put = new Put(Bytes.toBytes("row1"));
     put.add(fam, qual, 125l, value);
-    table.put(put);
+    puts.add(put);
+
     put = new Put(Bytes.toBytes("row1"));
     put.add(fam, qual, 126l, value);
-    table.put(put);
+    puts.add(put);
+
     put = new Put(Bytes.toBytes("row1"));
     put.add(fam, qual, 127l, value);
-    table.put(put);
+    puts.add(put);
+
+    Table table = new HTable(conf, tableName);
+    table.put(puts);
+
     TEST_UTIL.getHBaseAdmin().flush(tableName);
+
     put = new Put(Bytes.toBytes("row2"));
     put.add(fam, qual, 127l, value);
     table.put(put);
+
     return table;
   }
 
@@ -1057,19 +988,16 @@ public class TestVisibilityLabelsWithDeletes {
       throws Exception {
     setAuths();
     final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
-    Table table = null;
-    try {
-      table = doPuts(tableName);
+    try (Table table = doPuts(tableName)) {
       TEST_UTIL.getHBaseAdmin().flush(tableName);
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility("(" + PRIVATE + "&" + CONFIDENTIAL + ")|(" +
                 SECRET + "&" + TOPSECRET+")"));
-            d.deleteColumn(fam, qual, 125l);
+            d.addColumn(fam, qual, 125l);
             table.delete(d);
           } catch (Throwable t) {
             throw new IOException(t);
@@ -1117,10 +1045,6 @@ public class TestVisibilityLabelsWithDeletes {
       current = cellScanner.current();
       assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
           current.getRowLength(), row2, 0, row2.length));
-    } finally {
-      if (table != null) {
-        table.close();
-      }
     }
   }
 
@@ -1128,18 +1052,15 @@ public class TestVisibilityLabelsWithDeletes {
   public void testDeleteColumnWithLatestTimeStampUsingMultipleVersions() throws Exception {
     setAuths();
     final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
-    Table table = null;
-    try {
-      table = doPuts(tableName);
+    try (Table table = doPuts(tableName)) {
       TEST_UTIL.getHBaseAdmin().flush(tableName);
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility(SECRET + "&" + TOPSECRET));
-            d.deleteColumn(fam, qual);
+            d.addColumn(fam, qual);
             table.delete(d);
           } catch (Throwable t) {
             throw new IOException(t);
@@ -1182,10 +1103,6 @@ public class TestVisibilityLabelsWithDeletes {
       current = cellScanner.current();
       assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
           current.getRowLength(), row2, 0, row2.length));
-    } finally {
-      if (table != null) {
-        table.close();
-      }
     }
   }
 
@@ -1204,11 +1121,10 @@ public class TestVisibilityLabelsWithDeletes {
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility(SECRET ));
-            d.deleteColumn(fam, qual);
+            d.addColumn(fam, qual);
             table.delete(d);
           } catch (Throwable t) {
             throw new IOException(t);
@@ -1261,7 +1177,7 @@ public class TestVisibilityLabelsWithDeletes {
       put.add(fam, qual, 129l, value);
       put.setCellVisibility(new CellVisibility(SECRET));
       table.put(put);
-      table.flushCommits();
+
       TEST_UTIL.getHBaseAdmin().flush(tableName);
       s = new Scan();
       s.setMaxVersions(5);
@@ -1293,11 +1209,10 @@ public class TestVisibilityLabelsWithDeletes {
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility(SECRET + "&" + TOPSECRET));
-            d.deleteColumn(fam, qual);
+            d.addColumn(fam, qual);
             table.delete(d);
           } catch (Throwable t) {
             throw new IOException(t);
@@ -1365,11 +1280,10 @@ public class TestVisibilityLabelsWithDeletes {
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility(SECRET + "&" + TOPSECRET));
-            d.deleteFamily(fam);
+            d.addFamily(fam);
             table.delete(d);
           } catch (Throwable t) {
             throw new IOException(t);
@@ -1420,11 +1334,10 @@ public class TestVisibilityLabelsWithDeletes {
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
-            Delete d = new Delete(row1);
-            d.setCellVisibility(new CellVisibility(SECRET + "&" + TOPSECRET));
-            d.deleteColumns(fam, qual, 125l);
+          Delete d = new Delete(row1);
+          d.setCellVisibility(new CellVisibility(SECRET + "&" + TOPSECRET));
+          d.addColumns(fam, qual, 125l);
+          try (Table table = new HTable(conf, tableName)) {
             table.delete(d);
           } catch (Throwable t) {
             throw new IOException(t);
@@ -1476,15 +1389,13 @@ public class TestVisibilityLabelsWithDeletes {
   @Test
   public void testDeleteColumnsWithDiffColsAndTags() throws Exception {
     final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
-    Table table = null;
-    try {
-      Admin hBaseAdmin = TEST_UTIL.getHBaseAdmin();
-      HColumnDescriptor colDesc = new HColumnDescriptor(fam);
-      colDesc.setMaxVersions(5);
-      HTableDescriptor desc = new HTableDescriptor(tableName);
-      desc.addFamily(colDesc);
-      hBaseAdmin.createTable(desc);
-      table = new HTable(conf, tableName);
+    Admin hBaseAdmin = TEST_UTIL.getHBaseAdmin();
+    HColumnDescriptor colDesc = new HColumnDescriptor(fam);
+    colDesc.setMaxVersions(5);
+    HTableDescriptor desc = new HTableDescriptor(tableName);
+    desc.addFamily(colDesc);
+    hBaseAdmin.createTable(desc);
+    try (Table table = new HTable(conf, tableName)) {
       Put put = new Put(Bytes.toBytes("row1"));
       put.add(fam, qual1, 125l, value);
       put.setCellVisibility(new CellVisibility(CONFIDENTIAL));
@@ -1497,17 +1408,16 @@ public class TestVisibilityLabelsWithDeletes {
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
-            Delete d = new Delete(row1);
-            d.setCellVisibility(new CellVisibility(SECRET));
-            d.deleteColumns(fam, qual, 126l);
-            table.delete(d);
-            d = new Delete(row1);
-            d.setCellVisibility(new CellVisibility(CONFIDENTIAL));
-            d.deleteColumns(fam, qual1, 125l);
-            table.delete(d);
-            table.flushCommits();
+          Delete d1 = new Delete(row1);
+          d1.setCellVisibility(new CellVisibility(SECRET));
+          d1.addColumns(fam, qual, 126l);
+
+          Delete d2 = new Delete(row1);
+          d2.setCellVisibility(new CellVisibility(CONFIDENTIAL));
+          d2.addColumns(fam, qual1, 125l);
+
+          try (Table table = new HTable(conf, tableName)) {
+            table.delete(createList(d1, d2));
           } catch (Throwable t) {
             throw new IOException(t);
           }
@@ -1521,24 +1431,18 @@ public class TestVisibilityLabelsWithDeletes {
       ResultScanner scanner = table.getScanner(s);
       Result[] next = scanner.next(3);
       assertEquals(next.length, 1);
-    } finally {
-      if (table != null) {
-        table.close();
-      }
     }
   }
   @Test
   public void testDeleteColumnsWithDiffColsAndTags1() throws Exception {
     final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
-    Table table = null;
-    try {
-      Admin hBaseAdmin = TEST_UTIL.getHBaseAdmin();
-      HColumnDescriptor colDesc = new HColumnDescriptor(fam);
-      colDesc.setMaxVersions(5);
-      HTableDescriptor desc = new HTableDescriptor(tableName);
-      desc.addFamily(colDesc);
-      hBaseAdmin.createTable(desc);
-      table = new HTable(conf, tableName);
+    Admin hBaseAdmin = TEST_UTIL.getHBaseAdmin();
+    HColumnDescriptor colDesc = new HColumnDescriptor(fam);
+    colDesc.setMaxVersions(5);
+    HTableDescriptor desc = new HTableDescriptor(tableName);
+    desc.addFamily(colDesc);
+    hBaseAdmin.createTable(desc);
+    try (Table table = new HTable(conf, tableName)) {
       Put put = new Put(Bytes.toBytes("row1"));
       put.add(fam, qual1, 125l, value);
       put.setCellVisibility(new CellVisibility(CONFIDENTIAL));
@@ -1551,17 +1455,16 @@ public class TestVisibilityLabelsWithDeletes {
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
-            Delete d = new Delete(row1);
-            d.setCellVisibility(new CellVisibility(SECRET));
-            d.deleteColumns(fam, qual, 126l);
-            table.delete(d);
-            d = new Delete(row1);
-            d.setCellVisibility(new CellVisibility(CONFIDENTIAL));
-            d.deleteColumns(fam, qual1, 126l);
-            table.delete(d);
-            table.flushCommits();
+          Delete d1 = new Delete(row1);
+          d1.setCellVisibility(new CellVisibility(SECRET));
+          d1.addColumns(fam, qual, 126l);
+
+          Delete d2 = new Delete(row1);
+          d2.setCellVisibility(new CellVisibility(CONFIDENTIAL));
+          d2.addColumns(fam, qual1, 126l);
+
+          try (Table table = new HTable(conf, tableName)) {
+            table.delete(createList(d1, d2));
           } catch (Throwable t) {
             throw new IOException(t);
           }
@@ -1575,10 +1478,6 @@ public class TestVisibilityLabelsWithDeletes {
       ResultScanner scanner = table.getScanner(s);
       Result[] next = scanner.next(3);
       assertEquals(next.length, 1);
-    } finally {
-      if (table != null) {
-        table.close();
-      }
     }
   }
   @Test
@@ -1592,10 +1491,9 @@ public class TestVisibilityLabelsWithDeletes {
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
-            d.deleteFamily(fam);
+            d.addFamily(fam);
             table.delete(d);
           } catch (Throwable t) {
             throw new IOException(t);
@@ -1636,11 +1534,10 @@ public class TestVisibilityLabelsWithDeletes {
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility(SECRET + "&" + TOPSECRET));
-            d.deleteFamily(fam);
+            d.addFamily(fam);
             table.delete(d);
           } catch (Throwable t) {
             throw new IOException(t);
@@ -1705,12 +1602,11 @@ public class TestVisibilityLabelsWithDeletes {
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility("(" + PRIVATE + "&" + CONFIDENTIAL + ")|("
                 + SECRET + "&" + TOPSECRET + ")"));
-            d.deleteFamily(fam, 126l);
+            d.addFamily(fam, 126l);
             table.delete(d);
           } catch (Throwable t) {
             throw new IOException(t);
@@ -1766,12 +1662,11 @@ public class TestVisibilityLabelsWithDeletes {
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility("(" + PRIVATE + "&" + CONFIDENTIAL + ")|(" +
                 SECRET + "&" + TOPSECRET+")"));
-            d.deleteFamily(fam, 126l);
+            d.addFamily(fam, 126l);
             table.delete(d);
           } catch (Throwable t) {
             throw new IOException(t);
@@ -1825,12 +1720,11 @@ public class TestVisibilityLabelsWithDeletes {
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility("(" + PRIVATE + "&" + CONFIDENTIAL + ")|("
                 + TOPSECRET + "&" + SECRET+")"));
-            d.deleteFamily(fam, 125l);
+            d.addFamily(fam, 125l);
             table.delete(d);
           } catch (Throwable t) {
             throw new IOException(t);
@@ -1877,12 +1771,11 @@ public class TestVisibilityLabelsWithDeletes {
       actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility("(" + CONFIDENTIAL + "&" + PRIVATE + ")|("
                 + TOPSECRET + "&" + SECRET+")"));
-            d.deleteFamily(fam, 127l);
+            d.addFamily(fam, 127l);
             table.delete(d);
           } catch (Throwable t) {
             throw new IOException(t);
@@ -1937,13 +1830,11 @@ public class TestVisibilityLabelsWithDeletes {
     };
     VisibilityLabelsResponse response = SUPERUSER.runAs(action);
     final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
-    Table table = doPuts(tableName);
-    try {
+    try (Table table = doPuts(tableName);) {
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility(CONFIDENTIAL));
             d.deleteFamilyVersion(fam, 123l);
@@ -1983,10 +1874,6 @@ public class TestVisibilityLabelsWithDeletes {
       assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
           current.getRowLength(), row1, 0, row1.length));
       assertEquals(current.getTimestamp(), 124l);
-    } finally {
-      if (table != null) {
-        table.close();
-      }
     }
   }
 
@@ -1994,17 +1881,15 @@ public class TestVisibilityLabelsWithDeletes {
   public void testSpecificDeletesFollowedByDeleteFamily() throws Exception {
     setAuths();
     final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
-    Table table = doPuts(tableName);
-    try {
+    try (Table table = doPuts(tableName)){
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility("(" + CONFIDENTIAL + "&" + PRIVATE + ")|("
                 + TOPSECRET + "&" + SECRET + ")"));
-            d.deleteColumn(fam, qual, 126l);
+            d.addColumn(fam, qual, 126l);
             table.delete(d);
             d = new Delete(row1);
             d.setCellVisibility(new CellVisibility(SECRET + "&" + TOPSECRET));
@@ -2045,11 +1930,10 @@ public class TestVisibilityLabelsWithDeletes {
       actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility(CONFIDENTIAL));
-            d.deleteFamily(fam);
+            d.addFamily(fam);
             table.delete(d);
           } catch (Throwable t) {
             throw new IOException(t);
@@ -2075,10 +1959,6 @@ public class TestVisibilityLabelsWithDeletes {
       assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
           current.getRowLength(), row1, 0, row1.length));
       assertEquals(current.getTimestamp(), 124l);
-    } finally {
-      if (table != null) {
-        table.close();
-      }
     }
   }
 
@@ -2098,17 +1978,15 @@ public class TestVisibilityLabelsWithDeletes {
     };
     VisibilityLabelsResponse response = SUPERUSER.runAs(action);
     final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
-    Table table = doPuts(tableName);
-    try {
+    try (Table table = doPuts(tableName)){
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility("(" + CONFIDENTIAL + "&" + PRIVATE + ")|("
                 + TOPSECRET + "&" + SECRET + ")"));
-            d.deleteColumn(fam, qual);
+            d.addColumn(fam, qual);
             table.delete(d);
 
             d = new Delete(row1);
@@ -2150,11 +2028,10 @@ public class TestVisibilityLabelsWithDeletes {
       actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility(CONFIDENTIAL));
-            d.deleteFamily(fam);
+            d.addFamily(fam);
             table.delete(d);
           } catch (Throwable t) {
             throw new IOException(t);
@@ -2180,11 +2057,6 @@ public class TestVisibilityLabelsWithDeletes {
       assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
           current.getRowLength(), row1, 0, row1.length));
       assertEquals(current.getTimestamp(), 124l);
-
-    } finally {
-      if (table != null) {
-        table.close();
-      }
     }
   }
 
@@ -2192,18 +2064,14 @@ public class TestVisibilityLabelsWithDeletes {
   public void testDeleteColumnSpecificTimeStampWithMulipleVersionsDoneTwice() throws Exception {
     setAuths();
     final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
-    Table table = null;
-    try {
-      // Do not flush here.
-      table = doPuts(tableName);
+    try (Table table = doPuts(tableName)) {
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility(SECRET + "&" + TOPSECRET));
-            d.deleteColumn(fam, qual, 125l);
+            d.addColumn(fam, qual, 125l);
             table.delete(d);
           } catch (Throwable t) {
             throw new IOException(t);
@@ -2250,12 +2118,11 @@ public class TestVisibilityLabelsWithDeletes {
       actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility("(" + CONFIDENTIAL + "&" + PRIVATE + ")|("
                 + TOPSECRET + "&" + SECRET+")"));
-            d.deleteColumn(fam, qual, 127l);
+            d.addColumn(fam, qual, 127l);
             table.delete(d);
           } catch (Throwable t) {
             throw new IOException(t);
@@ -2292,10 +2159,6 @@ public class TestVisibilityLabelsWithDeletes {
       assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
           current.getRowLength(), row2, 0, row2.length));
       assertEquals(current.getTimestamp(), 127l);
-    } finally {
-      if (table != null) {
-        table.close();
-      }
     }
   }
 
@@ -2310,12 +2173,11 @@ public class TestVisibilityLabelsWithDeletes {
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility("(" + CONFIDENTIAL + "&" + PRIVATE + ")" +
                 "|(" + TOPSECRET + "&" + SECRET + ")"));
-            d.deleteColumn(fam, qual, 127l);
+            d.addColumn(fam, qual, 127l);
             table.delete(d);
           } catch (Throwable t) {
             throw new IOException(t);
@@ -2362,11 +2224,10 @@ public class TestVisibilityLabelsWithDeletes {
       actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility(SECRET + "&" + TOPSECRET));
-            d.deleteColumn(fam, qual, 127l);
+            d.addColumn(fam, qual, 127l);
             table.delete(d);
           } catch (Throwable t) {
             throw new IOException(t);
@@ -2425,12 +2286,11 @@ public class TestVisibilityLabelsWithDeletes {
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility("(" + PRIVATE + "&" + CONFIDENTIAL + ")|("
                 + TOPSECRET + "&" + SECRET+")"));
-            d.deleteColumn(fam, qual, 125l);
+            d.addColumn(fam, qual, 125l);
             table.delete(d);
           } catch (Throwable t) {
             throw new IOException(t);
@@ -2482,12 +2342,11 @@ public class TestVisibilityLabelsWithDeletes {
       actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility("(" + CONFIDENTIAL + "&" + PRIVATE + ")|("
                 + TOPSECRET + "&" + SECRET+")"));
-            d.deleteColumn(fam, qual, 127l);
+            d.addColumn(fam, qual, 127l);
             table.delete(d);
           } catch (Throwable t) {
             throw new IOException(t);
@@ -2547,11 +2406,10 @@ public class TestVisibilityLabelsWithDeletes {
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility(SECRET + "&" + TOPSECRET));
-            d.deleteColumn(fam, qual, 125l);
+            d.addColumn(fam, qual, 125l);
             table.delete(d);
           } catch (Throwable t) {
             throw new IOException(t);
@@ -2598,12 +2456,11 @@ public class TestVisibilityLabelsWithDeletes {
       actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility("(" + CONFIDENTIAL + "&" + PRIVATE + ")|("
                 + TOPSECRET + "&" + SECRET+")"));
-            d.deleteFamily(fam, 124l);
+            d.addFamily(fam, 124l);
             table.delete(d);
           } catch (Throwable t) {
             throw new IOException(t);
@@ -2662,19 +2519,16 @@ public class TestVisibilityLabelsWithDeletes {
   public void testDiffDeleteTypesForTheSameCellUsingMultipleVersions() throws Exception {
     setAuths();
     final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
-    Table table = null;
-    try {
+    try (Table table = doPuts(tableName)){
       // Do not flush here.
-      table = doPuts(tableName);
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility("(" + PRIVATE + "&" + CONFIDENTIAL + ")|("
                 + TOPSECRET + "&" + SECRET+")"));
-            d.deleteColumns(fam, qual, 125l);
+            d.addColumns(fam, qual, 125l);
             table.delete(d);
           } catch (Throwable t) {
             throw new IOException(t);
@@ -2721,12 +2575,11 @@ public class TestVisibilityLabelsWithDeletes {
       actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
             d.setCellVisibility(new CellVisibility("(" + CONFIDENTIAL + "&" + PRIVATE + ")|("
                 + TOPSECRET + "&" + SECRET+")"));
-            d.deleteColumn(fam, qual, 127l);
+            d.addColumn(fam, qual, 127l);
             table.delete(d);
           } catch (Throwable t) {
             throw new IOException(t);
@@ -2762,10 +2615,6 @@ public class TestVisibilityLabelsWithDeletes {
       current = cellScanner.current();
       assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
           current.getRowLength(), row2, 0, row2.length));
-    } finally {
-      if (table != null) {
-        table.close();
-      }
     }
   }
 
@@ -2773,17 +2622,14 @@ public class TestVisibilityLabelsWithDeletes {
   public void testDeleteColumnLatestWithNoCellVisibility() throws Exception {
     setAuths();
     final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
-    Table table = null;
-    try {
-      table = doPuts(tableName);
+    try (Table table = doPuts(tableName)){
       TEST_UTIL.getHBaseAdmin().flush(tableName);
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
-            d.deleteColumn(fam, qual, 125l);
+            d.addColumn(fam, qual, 125l);
             table.delete(d);
           } catch (Throwable t) {
             throw new IOException(t);
@@ -2804,10 +2650,9 @@ public class TestVisibilityLabelsWithDeletes {
       actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
-            d.deleteColumns(fam, qual, 125l);
+            d.addColumns(fam, qual, 125l);
             table.delete(d);
           } catch (Throwable t) {
             throw new IOException(t);
@@ -2829,10 +2674,9 @@ public class TestVisibilityLabelsWithDeletes {
       actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
-            d.deleteFamily(fam, 125l);
+            d.addFamily(fam, 125l);
             table.delete(d);
           } catch (Throwable t) {
             throw new IOException(t);
@@ -2854,10 +2698,9 @@ public class TestVisibilityLabelsWithDeletes {
       actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
-            d.deleteFamily(fam);
+            d.addFamily(fam);
             table.delete(d);
           } catch (Throwable t) {
             throw new IOException(t);
@@ -2879,10 +2722,9 @@ public class TestVisibilityLabelsWithDeletes {
       actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
-            d.deleteColumns(fam, qual);
+            d.addColumns(fam, qual);
             table.delete(d);
           } catch (Throwable t) {
             throw new IOException(t);
@@ -2904,8 +2746,7 @@ public class TestVisibilityLabelsWithDeletes {
       actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
             d.deleteFamilyVersion(fam, 126l);
             table.delete(d);
@@ -2925,10 +2766,6 @@ public class TestVisibilityLabelsWithDeletes {
       next = scanner.next(3);
       assertTrue(next.length == 2);
       scanAll(next);
-    } finally {
-      if (table != null) {
-        table.close();
-      }
     }
   }
 
@@ -2970,15 +2807,13 @@ public class TestVisibilityLabelsWithDeletes {
   public void testVisibilityExpressionWithNotEqualORCondition() throws Exception {
     setAuths();
     final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
-    Table table = null;
-    try {
-      Admin hBaseAdmin = TEST_UTIL.getHBaseAdmin();
-      HColumnDescriptor colDesc = new HColumnDescriptor(fam);
-      colDesc.setMaxVersions(5);
-      HTableDescriptor desc = new HTableDescriptor(tableName);
-      desc.addFamily(colDesc);
-      hBaseAdmin.createTable(desc);
-      table = new HTable(conf, tableName);
+    Admin hBaseAdmin = TEST_UTIL.getHBaseAdmin();
+    HColumnDescriptor colDesc = new HColumnDescriptor(fam);
+    colDesc.setMaxVersions(5);
+    HTableDescriptor desc = new HTableDescriptor(tableName);
+    desc.addFamily(colDesc);
+    hBaseAdmin.createTable(desc);
+    try (Table table = new HTable(conf, tableName)) {
       Put put = new Put(Bytes.toBytes("row1"));
       put.add(fam, qual, 123l, value);
       put.setCellVisibility(new CellVisibility(CONFIDENTIAL));
@@ -2991,10 +2826,9 @@ public class TestVisibilityLabelsWithDeletes {
       PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
         @Override
         public Void run() throws Exception {
-          try {
-            Table table = new HTable(conf, tableName);
+          try (Table table = new HTable(conf, tableName)) {
             Delete d = new Delete(row1);
-            d.deleteColumn(fam, qual, 124l);
+            d.addColumn(fam, qual, 124l);
             d.setCellVisibility(new CellVisibility(PRIVATE ));
             table.delete(d);
           } catch (Throwable t) {
@@ -3023,10 +2857,6 @@ public class TestVisibilityLabelsWithDeletes {
       assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
           current.getRowLength(), row1, 0, row1.length));
       assertEquals(current.getTimestamp(), 123l);
-    } finally {
-      if (table != null) {
-        table.close();
-      }
     }
   }
 
@@ -3082,4 +2912,9 @@ public class TestVisibilityLabelsWithDeletes {
     };
     SUPERUSER.runAs(action);
   }
+  
+  @SafeVarargs
+  public static <T> List<T> createList(T... ts) {
+    return new ArrayList<>(Arrays.asList(ts));
+  }
 }

http://git-wip-us.apache.org/repos/asf/hbase/blob/2452d386/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java
index 98753d0..4fa78f4 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java
@@ -699,7 +699,6 @@ public class TestHBaseFsck {
       //add a location with replicaId as 2 (since we already have replicas with replicaid 0 and 1)
       MetaTableAccessor.addLocation(put, sn, sn.getStartcode(), 2);
       meta.put(put);
-      meta.flushCommits();
       // assign the new replica
       HBaseFsckRepair.fixUnassigned(admin, newHri);
       HBaseFsckRepair.waitUntilAssigned(admin, newHri);
@@ -709,7 +708,6 @@ public class TestHBaseFsck {
       delete.addColumns(HConstants.CATALOG_FAMILY, MetaTableAccessor.getStartCodeColumn(2));
       delete.addColumns(HConstants.CATALOG_FAMILY, MetaTableAccessor.getSeqNumColumn(2));
       meta.delete(delete);
-      meta.flushCommits();
       meta.close();
       // check that problem exists
       HBaseFsck hbck = doFsck(conf, false);
@@ -1529,7 +1527,6 @@ public class TestHBaseFsck {
       hri.setSplit(true);
 
       MetaTableAccessor.addRegionToMeta(meta, hri, a, b);
-      meta.flushCommits();
       meta.close();
       admin.flush(TableName.META_TABLE_NAME);
 
@@ -1655,9 +1652,10 @@ public class TestHBaseFsck {
       undeployRegion(connection, hris.get(daughters.getFirst()), daughters.getFirst());
       undeployRegion(connection, hris.get(daughters.getSecond()), daughters.getSecond());
 
-      meta.delete(new Delete(daughters.getFirst().getRegionName()));
-      meta.delete(new Delete(daughters.getSecond().getRegionName()));
-      meta.flushCommits();
+      List<Delete> deletes = new ArrayList<>();
+      deletes.add(new Delete(daughters.getFirst().getRegionName()));
+      deletes.add(new Delete(daughters.getSecond().getRegionName()));
+      meta.delete(deletes);
 
       // Remove daughters from regionStates
       RegionStates regionStates = TEST_UTIL.getMiniHBaseCluster().getMaster().

http://git-wip-us.apache.org/repos/asf/hbase/blob/2452d386/hbase-server/src/test/java/org/apache/hadoop/hbase/util/hbck/OfflineMetaRebuildTestCore.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/hbck/OfflineMetaRebuildTestCore.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/hbck/OfflineMetaRebuildTestCore.java
index c5aaf90..6c33a9b 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/hbck/OfflineMetaRebuildTestCore.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/hbck/OfflineMetaRebuildTestCore.java
@@ -31,14 +31,14 @@ import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FSDataOutputStream;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.HColumnDescriptor;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.HTableDescriptor;
+import org.apache.hadoop.hbase.MetaTableAccessor;
 import org.apache.hadoop.hbase.NamespaceDescriptor;
 import org.apache.hadoop.hbase.ServerName;
-import org.apache.hadoop.hbase.MetaTableAccessor;
+import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.client.Admin;
 import org.apache.hadoop.hbase.client.Connection;
 import org.apache.hadoop.hbase.client.ConnectionFactory;
@@ -147,15 +147,16 @@ public class OfflineMetaRebuildTestCore {
 
   private void populateTable(Table tbl) throws IOException {
     byte[] values = { 'A', 'B', 'C', 'D' };
+    List<Put> puts = new ArrayList<>();
     for (int i = 0; i < values.length; i++) {
       for (int j = 0; j < values.length; j++) {
         Put put = new Put(new byte[] { values[i], values[j] });
         put.add(Bytes.toBytes("fam"), new byte[] {}, new byte[] { values[i],
             values[j] });
-        tbl.put(put);
+        puts.add(put);
       }
     }
-    tbl.flushCommits();
+    tbl.put(puts);
   }
 
   /**
@@ -253,7 +254,6 @@ public class OfflineMetaRebuildTestCore {
       }
     }
     meta.delete(dels);
-    meta.flushCommits();
     scanner.close();
     meta.close();
   }

http://git-wip-us.apache.org/repos/asf/hbase/blob/2452d386/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/TestWALFiltering.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/TestWALFiltering.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/TestWALFiltering.java
index a3e38b3..66868a1 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/TestWALFiltering.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/TestWALFiltering.java
@@ -91,14 +91,13 @@ public class TestWALFiltering {
                 ts + "_random_" + rand.nextLong());
             put.add(cf, qual, ts, value);
           } else if (rand.nextDouble() < 0.8) {
-            del.deleteColumn(cf, qual, ts);
+            del.addColumn(cf, qual, ts);
           } else {
-            del.deleteColumns(cf, qual, ts);
+            del.addColumn(cf, qual, ts);
           }
         }
         table.put(put);
         table.delete(del);
-        table.flushCommits();
       }
     }
     TEST_UTIL.waitUntilAllRegionsAssigned(TABLE_NAME);


[2/2] hbase git commit: HBASE-12802 Remove unnecessary Table.flushCommits() (Solomon Duskis)

Posted by te...@apache.org.
HBASE-12802 Remove unnecessary Table.flushCommits() (Solomon Duskis)


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/2452d386
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/2452d386
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/2452d386

Branch: refs/heads/master
Commit: 2452d3861fb56c9ce7d748c32230b2df7798efc0
Parents: 5b53a18
Author: tedyu <yu...@gmail.com>
Authored: Mon Jan 5 15:45:52 2015 -0800
Committer: tedyu <yu...@gmail.com>
Committed: Mon Jan 5 15:45:52 2015 -0800

----------------------------------------------------------------------
 .../hadoop/hbase/mttr/IntegrationTestMTTR.java  |   1 -
 .../test/IntegrationTestBigLinkedList.java      |   2 -
 .../hadoop/hbase/rest/TestScannerResource.java  |  35 +-
 .../hbase/rest/TestScannersWithLabels.java      |  15 +-
 .../org/apache/hadoop/hbase/util/HBaseFsck.java |   2 -
 .../hadoop/hbase/HBaseTestingUtility.java       |  20 +-
 .../hadoop/hbase/client/TestFastFail.java       |  29 +-
 .../hadoop/hbase/client/TestFromClientSide.java |   6 -
 .../hbase/client/TestFromClientSide3.java       |   1 -
 .../client/TestSnapshotCloneIndependence.java   |  18 +-
 .../coprocessor/TestOpenTableInCoprocessor.java |   2 -
 .../TestRegionObserverInterface.java            |   6 +-
 .../TestRegionObserverScannerOpenHook.java      |   2 -
 .../hbase/io/encoding/TestChangingEncoding.java |  13 +-
 .../hbase/io/encoding/TestPrefixTree.java       |   5 -
 .../hbase/mapreduce/TestImportExport.java       |  23 +-
 .../hbase/mapreduce/TestTimeRangeMapRed.java    |  21 +-
 .../hbase/regionserver/TestCompactionState.java |   1 -
 .../TestEndToEndSplitTransaction.java           |   7 +-
 .../regionserver/TestRegionServerMetrics.java   |  12 -
 .../replication/TestReplicationSmallTests.java  |  20 +-
 .../visibility/TestVisibilityLabels.java        |  25 +-
 .../TestVisibilityLabelsWithDeletes.java        | 783 ++++++++-----------
 .../apache/hadoop/hbase/util/TestHBaseFsck.java |  10 +-
 .../util/hbck/OfflineMetaRebuildTestCore.java   |  10 +-
 .../hadoop/hbase/wal/TestWALFiltering.java      |   5 +-
 26 files changed, 428 insertions(+), 646 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/2452d386/hbase-it/src/test/java/org/apache/hadoop/hbase/mttr/IntegrationTestMTTR.java
----------------------------------------------------------------------
diff --git a/hbase-it/src/test/java/org/apache/hadoop/hbase/mttr/IntegrationTestMTTR.java b/hbase-it/src/test/java/org/apache/hadoop/hbase/mttr/IntegrationTestMTTR.java
index f64528b..63430a1 100644
--- a/hbase-it/src/test/java/org/apache/hadoop/hbase/mttr/IntegrationTestMTTR.java
+++ b/hbase-it/src/test/java/org/apache/hadoop/hbase/mttr/IntegrationTestMTTR.java
@@ -486,7 +486,6 @@ public class IntegrationTestMTTR {
       Put p = new Put(Bytes.toBytes(RandomStringUtils.randomAlphanumeric(5)));
       p.add(FAMILY, Bytes.toBytes("\0"), Bytes.toBytes(RandomStringUtils.randomAscii(5)));
       table.put(p);
-      table.flushCommits();
       return true;
     }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/2452d386/hbase-it/src/test/java/org/apache/hadoop/hbase/test/IntegrationTestBigLinkedList.java
----------------------------------------------------------------------
diff --git a/hbase-it/src/test/java/org/apache/hadoop/hbase/test/IntegrationTestBigLinkedList.java b/hbase-it/src/test/java/org/apache/hadoop/hbase/test/IntegrationTestBigLinkedList.java
index 259de65..c7dae78 100644
--- a/hbase-it/src/test/java/org/apache/hadoop/hbase/test/IntegrationTestBigLinkedList.java
+++ b/hbase-it/src/test/java/org/apache/hadoop/hbase/test/IntegrationTestBigLinkedList.java
@@ -927,9 +927,7 @@ public class IntegrationTestBigLinkedList extends IntegrationTestBase {
         = new org.apache.hadoop.hbase.client.Delete(val);
 
       Table table = new HTable(getConf(), getTableName(getConf()));
-
       table.delete(delete);
-      table.flushCommits();
       table.close();
 
       System.out.println("Delete successful");

http://git-wip-us.apache.org/repos/asf/hbase/blob/2452d386/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannerResource.java
----------------------------------------------------------------------
diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannerResource.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannerResource.java
index 2387b98..4f4f698 100644
--- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannerResource.java
+++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannerResource.java
@@ -19,10 +19,17 @@
 
 package org.apache.hadoop.hbase.rest;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.StringWriter;
+import java.util.ArrayList;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Random;
 
 import javax.xml.bind.JAXBContext;
@@ -32,11 +39,16 @@ import javax.xml.bind.Unmarshaller;
 
 import org.apache.commons.httpclient.Header;
 import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.*;
+import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.HColumnDescriptor;
+import org.apache.hadoop.hbase.HTableDescriptor;
+import org.apache.hadoop.hbase.KeyValue;
+import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.client.Admin;
-import org.apache.hadoop.hbase.client.HTable;
-import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.client.Connection;
+import org.apache.hadoop.hbase.client.ConnectionFactory;
 import org.apache.hadoop.hbase.client.Durability;
+import org.apache.hadoop.hbase.client.Put;
 import org.apache.hadoop.hbase.client.Table;
 import org.apache.hadoop.hbase.rest.client.Client;
 import org.apache.hadoop.hbase.rest.client.Cluster;
@@ -48,9 +60,6 @@ import org.apache.hadoop.hbase.rest.model.ScannerModel;
 import org.apache.hadoop.hbase.testclassification.MediumTests;
 import org.apache.hadoop.hbase.testclassification.RestTests;
 import org.apache.hadoop.hbase.util.Bytes;
-
-import static org.junit.Assert.*;
-
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -79,10 +88,9 @@ public class TestScannerResource {
   static int insertData(Configuration conf, TableName tableName, String column, double prob)
       throws IOException {
     Random rng = new Random();
-    int count = 0;
-    Table table = new HTable(conf, tableName);
     byte[] k = new byte[3];
     byte [][] famAndQf = KeyValue.parseColumn(Bytes.toBytes(column));
+    List<Put> puts = new ArrayList<>();
     for (byte b1 = 'a'; b1 < 'z'; b1++) {
       for (byte b2 = 'a'; b2 < 'z'; b2++) {
         for (byte b3 = 'a'; b3 < 'z'; b3++) {
@@ -93,15 +101,16 @@ public class TestScannerResource {
             Put put = new Put(k);
             put.setDurability(Durability.SKIP_WAL);
             put.add(famAndQf[0], famAndQf[1], k);
-            table.put(put);
-            count++;
+            puts.add(put);
           }
         }
       }
     }
-    table.flushCommits();
-    table.close();
-    return count;
+    try (Connection conn = ConnectionFactory.createConnection(conf);
+        Table table = conn.getTable(tableName)) {
+      table.put(puts);
+    }
+    return puts.size();
   }
 
   static int countCellSet(CellSetModel model) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/2452d386/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannersWithLabels.java
----------------------------------------------------------------------
diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannersWithLabels.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannersWithLabels.java
index ca48ea8..5745954 100644
--- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannersWithLabels.java
+++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannersWithLabels.java
@@ -24,7 +24,9 @@ import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.StringWriter;
 import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Random;
 
 import javax.xml.bind.JAXBContext;
@@ -90,23 +92,22 @@ public class TestScannersWithLabels {
   private static Configuration conf;
 
   private static int insertData(TableName tableName, String column, double prob) throws IOException {
-    Random rng = new Random();
-    int count = 0;
-    Table table = new HTable(TEST_UTIL.getConfiguration(), tableName);
     byte[] k = new byte[3];
     byte[][] famAndQf = KeyValue.parseColumn(Bytes.toBytes(column));
 
+    List<Put> puts = new ArrayList<>();
     for (int i = 0; i < 9; i++) {
       Put put = new Put(Bytes.toBytes("row" + i));
       put.setDurability(Durability.SKIP_WAL);
       put.add(famAndQf[0], famAndQf[1], k);
       put.setCellVisibility(new CellVisibility("(" + SECRET + "|" + CONFIDENTIAL + ")" + "&" + "!"
           + TOPSECRET));
-      table.put(put);
-      count++;
+      puts.add(put);
     }
-    table.flushCommits();
-    return count;
+    try (Table table = new HTable(TEST_UTIL.getConfiguration(), tableName)) {
+      table.put(puts);
+    }
+    return puts.size();
   }
 
   private static int countCellSet(CellSetModel model) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/2452d386/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
index 248d1d8..94da7ab 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
@@ -1739,7 +1739,6 @@ public class HBaseFsck extends Configured implements Closeable {
   private void deleteMetaRegion(byte[] metaKey) throws IOException {
     Delete d = new Delete(metaKey);
     meta.delete(d);
-    meta.flushCommits();
     LOG.info("Deleted " + Bytes.toString(metaKey) + " from META" );
   }
 
@@ -1760,7 +1759,6 @@ public class HBaseFsck extends Configured implements Closeable {
     mutations.add(p);
 
     meta.mutateRow(mutations);
-    meta.flushCommits();
     LOG.info("Reset split parent " + hi.metaEntry.getRegionNameAsString() + " in META" );
   }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/2452d386/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
index 3038ad7..6b4394f 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
@@ -1878,7 +1878,7 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility {
    * @return Count of rows loaded.
    * @throws IOException
    */
-  public int loadTable(final HTable t, final byte[] f) throws IOException {
+  public int loadTable(final Table t, final byte[] f) throws IOException {
     return loadTable(t, new byte[][] {f});
   }
 
@@ -1889,7 +1889,7 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility {
    * @return Count of rows loaded.
    * @throws IOException
    */
-  public int loadTable(final HTable t, final byte[] f, boolean writeToWAL) throws IOException {
+  public int loadTable(final Table t, final byte[] f, boolean writeToWAL) throws IOException {
     return loadTable(t, new byte[][] {f}, null, writeToWAL);
   }
 
@@ -1900,7 +1900,7 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility {
    * @return Count of rows loaded.
    * @throws IOException
    */
-  public int loadTable(final HTable t, final byte[][] f) throws IOException {
+  public int loadTable(final Table t, final byte[][] f) throws IOException {
     return loadTable(t, f, null);
   }
 
@@ -1912,7 +1912,7 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility {
    * @return Count of rows loaded.
    * @throws IOException
    */
-  public int loadTable(final HTable t, final byte[][] f, byte[] value) throws IOException {
+  public int loadTable(final Table t, final byte[][] f, byte[] value) throws IOException {
     return loadTable(t, f, value, true);
   }
 
@@ -1924,20 +1924,18 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility {
    * @return Count of rows loaded.
    * @throws IOException
    */
-  public int loadTable(final HTable t, final byte[][] f, byte[] value, boolean writeToWAL) throws IOException {
-    t.setAutoFlushTo(false);
-    int rowCount = 0;
+  public int loadTable(final Table t, final byte[][] f, byte[] value, boolean writeToWAL) throws IOException {
+    List<Put> puts = new ArrayList<>();
     for (byte[] row : HBaseTestingUtility.ROWS) {
       Put put = new Put(row);
       put.setDurability(writeToWAL ? Durability.USE_DEFAULT : Durability.SKIP_WAL);
       for (int i = 0; i < f.length; i++) {
         put.add(f[i], null, value != null ? value : row);
       }
-      t.put(put);
-      rowCount++;
+      puts.add(put);
     }
-    t.flushCommits();
-    return rowCount;
+    t.put(puts);
+    return puts.size();
   }
 
   /** A tracker for tracking and validating table rows

http://git-wip-us.apache.org/repos/asf/hbase/blob/2452d386/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFastFail.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFastFail.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFastFail.java
index 709e94b..10aa1f1 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFastFail.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFastFail.java
@@ -17,7 +17,8 @@
  */
 package org.apache.hadoop.hbase.client;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -119,8 +120,17 @@ public class TestFastFail {
     /**
      * Write numRows worth of data, so that the workers can arbitrarily read.
      */
-    try (Table table = connection.getTable(TableName.valueOf(tableName));) {
-      writeData(table, numRows);
+    List<Put> puts = new ArrayList<>();
+    for (long i = 0; i < numRows; i++) {
+      byte[] rowKey = longToByteArrayKey(i);
+      Put put = new Put(rowKey);
+      byte[] value = rowKey; // value is the same as the row key
+      put.add(FAMILY, QUALIFIER, value);
+      puts.add(put);
+    }
+    try (Table table = connection.getTable(TableName.valueOf(tableName))) {
+      table.put(puts);
+      LOG.info("Written all puts.");
     }
 
     /**
@@ -297,17 +307,4 @@ public class TestFastFail {
   private byte[] longToByteArrayKey(long rowKey) {
     return LoadTestKVGenerator.md5PrefixedKey(rowKey).getBytes();
   }
-
-  public void writeData(Table table, long numRows) throws IOException,
-      InterruptedException {
-    table.flushCommits();
-    for (long i = 0; i < numRows; i++) {
-      byte[] rowKey = longToByteArrayKey(i);
-      Put put = new Put(rowKey);
-      byte[] value = rowKey; // value is the same as the row key
-      put.add(FAMILY, QUALIFIER, value);
-      table.put(put);
-    }
-    LOG.info("Written all puts.");
-  }
 }

http://git-wip-us.apache.org/repos/asf/hbase/blob/2452d386/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
index fa69c47..c6b5830 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
@@ -5506,22 +5506,17 @@ public class TestFromClientSide {
     Put p = new Put(row);
     p.add(FAMILY, QUALIFIER, 10, VALUE);
     table.put(p);
-    table.flushCommits();
-
     p = new Put(row);
     p.add(FAMILY, QUALIFIER, 11, ArrayUtils.add(VALUE, (byte) 2));
     table.put(p);
-    table.flushCommits();
 
     p = new Put(row);
     p.add(FAMILY, QUALIFIER, 12, ArrayUtils.add(VALUE, (byte) 3));
     table.put(p);
-    table.flushCommits();
 
     p = new Put(row);
     p.add(FAMILY, QUALIFIER, 13, ArrayUtils.add(VALUE, (byte) 4));
     table.put(p);
-    table.flushCommits();
 
     int versions = 4;
     Scan s = new Scan(row);
@@ -5642,7 +5637,6 @@ public class TestFromClientSide {
     put = new Put(Bytes.toBytes("0-b22222-0000000000000000009"));
     put.add(FAMILY, QUALIFIER, VALUE);
     ht.put(put);
-    ht.flushCommits();
     Scan scan = new Scan(Bytes.toBytes("0-b11111-9223372036854775807"),
         Bytes.toBytes("0-b11111-0000000000000000000"));
     scan.setReversed(true);

http://git-wip-us.apache.org/repos/asf/hbase/blob/2452d386/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide3.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide3.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide3.java
index 0e97684..2729e97 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide3.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide3.java
@@ -413,7 +413,6 @@ public class TestFromClientSide3 {
     Put put = new Put(ROW_BYTES);
     put.add(FAMILY, COL_QUAL, VAL_BYTES);
     table.put(put);
-    table.flushCommits();
 
     //Try getting the row with an empty row key
     Result res = null;

http://git-wip-us.apache.org/repos/asf/hbase/blob/2452d386/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSnapshotCloneIndependence.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSnapshotCloneIndependence.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSnapshotCloneIndependence.java
index 1d9ff1e..b4c6b3b 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSnapshotCloneIndependence.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSnapshotCloneIndependence.java
@@ -173,7 +173,7 @@ public class TestSnapshotCloneIndependence {
         // Restore the interrupted status
         Thread.currentThread().interrupt();
       }
-      if (t.getRegionLocations().size() > originalCount) {
+      if (t.getAllRegionLocations().size() > originalCount) {
         return;
       }
     }
@@ -194,9 +194,7 @@ public class TestSnapshotCloneIndependence {
     final TableName localTableName =
         TableName.valueOf(STRING_TABLE_NAME + startTime);
 
-    HTable original = UTIL.createTable(localTableName, TEST_FAM);
-    try {
-
+    try (Table original = UTIL.createTable(localTableName, TEST_FAM)) {
       UTIL.loadTable(original, TEST_FAM);
       final int origTableRowCount = UTIL.countRows(original);
 
@@ -213,9 +211,7 @@ public class TestSnapshotCloneIndependence {
       TableName cloneTableName = TableName.valueOf("test-clone-" + localTableName);
       admin.cloneSnapshot(snapshotName, cloneTableName);
 
-      Table clonedTable = new HTable(UTIL.getConfiguration(), cloneTableName);
-
-      try {
+      try (Table clonedTable = new HTable(UTIL.getConfiguration(), cloneTableName)){
         final int clonedTableRowCount = UTIL.countRows(clonedTable);
 
         Assert.assertEquals(
@@ -228,7 +224,6 @@ public class TestSnapshotCloneIndependence {
         Put p = new Put(Bytes.toBytes(rowKey));
         p.add(TEST_FAM, Bytes.toBytes("someQualifier"), Bytes.toBytes("someString"));
         original.put(p);
-        original.flushCommits();
 
         // Verify that it is not present in the original table
         Assert.assertEquals("The row count of the original table was not modified by the put",
@@ -240,7 +235,6 @@ public class TestSnapshotCloneIndependence {
         p = new Put(Bytes.toBytes(rowKey));
         p.add(TEST_FAM, Bytes.toBytes("someQualifier"), Bytes.toBytes("someString"));
         clonedTable.put(p);
-        clonedTable.flushCommits();
 
         // Verify that the new family is not in the restored table's description
         Assert.assertEquals(
@@ -248,13 +242,7 @@ public class TestSnapshotCloneIndependence {
           origTableRowCount + 1, UTIL.countRows(original));
         Assert.assertEquals("The row count of the cloned table was not modified by the put",
           clonedTableRowCount + 1, UTIL.countRows(clonedTable));
-      } finally {
-
-        clonedTable.close();
       }
-    } finally {
-
-      original.close();
     }
   }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/2452d386/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestOpenTableInCoprocessor.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestOpenTableInCoprocessor.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestOpenTableInCoprocessor.java
index 57db176..c5af6d5 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestOpenTableInCoprocessor.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestOpenTableInCoprocessor.java
@@ -71,7 +71,6 @@ public class TestOpenTableInCoprocessor {
         final WALEdit edit, final Durability durability) throws IOException {
       Table table = e.getEnvironment().getTable(otherTable);
       table.put(put);
-      table.flushCommits();
       completed[0] = true;
       table.close();
     }
@@ -166,7 +165,6 @@ public class TestOpenTableInCoprocessor {
     Put p = new Put(new byte[] { 'a' });
     p.add(family, null, new byte[] { 'a' });
     table.put(p);
-    table.flushCommits();
     table.close();
 
     Table target = new HTable(UTIL.getConfiguration(), otherTable);

http://git-wip-us.apache.org/repos/asf/hbase/blob/2452d386/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverInterface.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverInterface.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverInterface.java
index 882aece..0f161d9 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverInterface.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverInterface.java
@@ -244,12 +244,10 @@ public class TestRegionObserverInterface {
   public void testCheckAndPutHooks() throws IOException {
     TableName tableName =
         TableName.valueOf(TEST_TABLE.getNameAsString() + ".testCheckAndPutHooks");
-    Table table = util.createTable(tableName, new byte[][] {A, B, C});
-    try {
+    try (Table table = util.createTable(tableName, new byte[][] {A, B, C})) {
       Put p = new Put(Bytes.toBytes(0));
       p.add(A, A, A);
       table.put(p);
-      table.flushCommits();
       p = new Put(Bytes.toBytes(0));
       p.add(A, A, A);
       verifyMethodResult(SimpleRegionObserver.class,
@@ -267,7 +265,6 @@ public class TestRegionObserverInterface {
           );
     } finally {
       util.deleteTable(tableName);
-      table.close();
     }
   }
 
@@ -280,7 +277,6 @@ public class TestRegionObserverInterface {
       Put p = new Put(Bytes.toBytes(0));
       p.add(A, A, A);
       table.put(p);
-      table.flushCommits();
       Delete d = new Delete(Bytes.toBytes(0));
       table.delete(d);
       verifyMethodResult(SimpleRegionObserver.class,

http://git-wip-us.apache.org/repos/asf/hbase/blob/2452d386/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverScannerOpenHook.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverScannerOpenHook.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverScannerOpenHook.java
index 76e3209..8742066 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverScannerOpenHook.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverScannerOpenHook.java
@@ -265,7 +265,6 @@ public class TestRegionObserverScannerOpenHook {
     Put put = new Put(ROW);
     put.add(A, A, A);
     table.put(put);
-    table.flushCommits();
 
     HRegionServer rs = UTIL.getRSForFirstRegionInTable(desc.getTableName());
     List<HRegion> regions = rs.getOnlineRegions(desc.getTableName());
@@ -279,7 +278,6 @@ public class TestRegionObserverScannerOpenHook {
     put = new Put(Bytes.toBytes("anotherrow"));
     put.add(A, A, A);
     table.put(put);
-    table.flushCommits();
     admin.flushRegion(region.getRegionName());
 
     // run a compaction, which normally would should get rid of the data

http://git-wip-us.apache.org/repos/asf/hbase/blob/2452d386/hbase-server/src/test/java/org/apache/hadoop/hbase/io/encoding/TestChangingEncoding.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/encoding/TestChangingEncoding.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/encoding/TestChangingEncoding.java
index e002b8b..fdbef44 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/encoding/TestChangingEncoding.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/encoding/TestChangingEncoding.java
@@ -36,6 +36,8 @@ import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.client.Admin;
+import org.apache.hadoop.hbase.client.Connection;
+import org.apache.hadoop.hbase.client.ConnectionFactory;
 import org.apache.hadoop.hbase.client.Durability;
 import org.apache.hadoop.hbase.client.Get;
 import org.apache.hadoop.hbase.client.HBaseAdmin;
@@ -128,8 +130,7 @@ public class TestChangingEncoding {
   static void writeTestDataBatch(Configuration conf, TableName tableName,
       int batchId) throws Exception {
     LOG.debug("Writing test data batch " + batchId);
-    Table table = new HTable(conf, tableName);
-    table.setAutoFlushTo(false);
+    List<Put> puts = new ArrayList<>();
     for (int i = 0; i < NUM_ROWS_PER_BATCH; ++i) {
       Put put = new Put(getRowKey(batchId, i));
       for (int j = 0; j < NUM_COLS_PER_ROW; ++j) {
@@ -137,10 +138,12 @@ public class TestChangingEncoding {
             getValue(batchId, i, j));
       }
       put.setDurability(Durability.SKIP_WAL);
-      table.put(put);
+      puts.add(put);
+    }
+    try (Connection conn = ConnectionFactory.createConnection(conf);
+        Table table = conn.getTable(tableName)) {
+      table.put(puts);
     }
-    table.flushCommits();
-    table.close();
   }
 
   static void verifyTestDataBatch(Configuration conf, TableName tableName,

http://git-wip-us.apache.org/repos/asf/hbase/blob/2452d386/hbase-server/src/test/java/org/apache/hadoop/hbase/io/encoding/TestPrefixTree.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/encoding/TestPrefixTree.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/encoding/TestPrefixTree.java
index cc74498..2562b10 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/encoding/TestPrefixTree.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/encoding/TestPrefixTree.java
@@ -94,23 +94,18 @@ public class TestPrefixTree {
       Put put = new Put(Bytes.toBytes("a-b-0-0"));
       put.add(fam, qual1, Bytes.toBytes("c1-value"));
       table.put(put);
-      table.flushCommits();
       put = new Put(row1_bytes);
       put.add(fam, qual1, Bytes.toBytes("c1-value"));
       table.put(put);
-      table.flushCommits();
       put = new Put(row2_bytes);
       put.add(fam, qual2, Bytes.toBytes("c2-value"));
       table.put(put);
-      table.flushCommits();
       put = new Put(row3_bytes);
       put.add(fam, qual2, Bytes.toBytes("c2-value-2"));
       table.put(put);
-      table.flushCommits();
       put = new Put(row4_bytes);
       put.add(fam, qual2, Bytes.toBytes("c2-value-3"));
       table.put(put);
-      table.flushCommits();
       hBaseAdmin.flush(tableName);
       String[] rows = new String[3];
       rows[0] = row1;

http://git-wip-us.apache.org/repos/asf/hbase/blob/2452d386/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportExport.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportExport.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportExport.java
index a2df105..e828fa6 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportExport.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportExport.java
@@ -31,6 +31,7 @@ import java.io.IOException;
 import java.io.PrintStream;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 import org.apache.hadoop.conf.Configuration;
@@ -430,20 +431,18 @@ public class TestImportExport {
     UTIL.getHBaseAdmin().createTable(desc);
     Table exportTable = new HTable(UTIL.getConfiguration(), desc.getTableName());
 
-    Put p = new Put(ROW1);
-    p.add(FAMILYA, QUAL, now, QUAL);
-    p.add(FAMILYA, QUAL, now + 1, QUAL);
-    p.add(FAMILYA, QUAL, now + 2, QUAL);
-    p.add(FAMILYA, QUAL, now + 3, QUAL);
-    p.add(FAMILYA, QUAL, now + 4, QUAL);
-    exportTable.put(p);
+    Put p1 = new Put(ROW1);
+    p1.add(FAMILYA, QUAL, now, QUAL);
+    p1.add(FAMILYA, QUAL, now + 1, QUAL);
+    p1.add(FAMILYA, QUAL, now + 2, QUAL);
+    p1.add(FAMILYA, QUAL, now + 3, QUAL);
+    p1.add(FAMILYA, QUAL, now + 4, QUAL);
 
     // Having another row would actually test the filter.
-    p = new Put(ROW2);
-    p.add(FAMILYA, QUAL, now, QUAL);
-    exportTable.put(p);
-    // Flush the commits.
-    exportTable.flushCommits();
+    Put p2 = new Put(ROW2);
+    p2.add(FAMILYA, QUAL, now, QUAL);
+
+    exportTable.put(Arrays.asList(p1, p2));
 
     // Export the simple table
     String[] args = new String[] { EXPORT_TABLE, FQ_OUTPUT_DIR, "1000" };

http://git-wip-us.apache.org/repos/asf/hbase/blob/2452d386/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTimeRangeMapRed.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTimeRangeMapRed.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTimeRangeMapRed.java
index b701c35..f138348 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTimeRangeMapRed.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTimeRangeMapRed.java
@@ -118,13 +118,14 @@ public class TestTimeRangeMapRed {
         tsList.add(kv.getTimestamp());
       }
 
+      List<Put> puts = new ArrayList<>();
       for (Long ts : tsList) {
         Put put = new Put(key.get());
         put.setDurability(Durability.SKIP_WAL);
         put.add(FAMILY_NAME, COLUMN_NAME, ts, Bytes.toBytes(true));
-        table.put(put);
+        puts.add(put);
       }
-      table.flushCommits();
+      table.put(puts);
     }
 
     @Override
@@ -151,20 +152,18 @@ public class TestTimeRangeMapRed {
     col.setMaxVersions(Integer.MAX_VALUE);
     desc.addFamily(col);
     admin.createTable(desc);
-    Table table = new HTable(UTIL.getConfiguration(), desc.getTableName());
-    prepareTest(table);
-    runTestOnTable();
-    verify(table);
-  }
-
-  private void prepareTest(final Table table) throws IOException {
+    List<Put> puts = new ArrayList<Put>();
     for (Map.Entry<Long, Boolean> entry : TIMESTAMP.entrySet()) {
       Put put = new Put(KEY);
       put.setDurability(Durability.SKIP_WAL);
       put.add(FAMILY_NAME, COLUMN_NAME, entry.getKey(), Bytes.toBytes(false));
-      table.put(put);
+      puts.add(put);
     }
-    table.flushCommits();
+    Table table = new HTable(UTIL.getConfiguration(), desc.getTableName());
+    table.put(puts);
+    runTestOnTable();
+    verify(table);
+    table.close();
   }
 
   private void runTestOnTable()

http://git-wip-us.apache.org/repos/asf/hbase/blob/2452d386/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompactionState.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompactionState.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompactionState.java
index 4311b29..3ba01bc 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompactionState.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompactionState.java
@@ -227,7 +227,6 @@ public class TestCompactionState {
         puts.add(p);
       }
       ht.put(puts);
-      ht.flushCommits();
       TEST_UTIL.flush();
       puts.clear();
     }

http://git-wip-us.apache.org/repos/asf/hbase/blob/2452d386/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestEndToEndSplitTransaction.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestEndToEndSplitTransaction.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestEndToEndSplitTransaction.java
index 3f70a9b..8b7edeb 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestEndToEndSplitTransaction.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestEndToEndSplitTransaction.java
@@ -23,6 +23,7 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.NavigableMap;
@@ -284,13 +285,13 @@ public class TestEndToEndSplitTransaction {
     }
 
     void addData(int start) throws IOException {
+      List<Put> puts = new ArrayList<>();
       for (int i=start; i< start + 100; i++) {
         Put put = new Put(Bytes.toBytes(i));
-
         put.add(family, family, Bytes.toBytes(i));
-        table.put(put);
+        puts.add(put);
       }
-      table.flushCommits();
+      table.put(puts);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/2452d386/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerMetrics.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerMetrics.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerMetrics.java
index d3285a3..4471f76 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerMetrics.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerMetrics.java
@@ -198,7 +198,6 @@ public class TestRegionServerMetrics {
     p.setDurability(Durability.SKIP_WAL);
 
     t.put(p);
-    t.flushCommits();
 
     metricsRegionServer.getRegionServerWrapper().forceRecompute();
     metricsHelper.assertGauge("mutationsWithoutWALCount", 1, serverSource);
@@ -227,7 +226,6 @@ public class TestRegionServerMetrics {
     Put p = new Put(row);
     p.add(cf, qualifier, val);
     t.put(p);
-    t.flushCommits();
     TEST_UTIL.getHBaseAdmin().flush(tableName);
 
     metricsRegionServer.getRegionServerWrapper().forceRecompute();
@@ -253,18 +251,14 @@ public class TestRegionServerMetrics {
     Put p = new Put(row);
     p.add(cf, qualifier, valOne);
     t.put(p);
-    t.flushCommits();
 
     Put pTwo = new Put(row);
     pTwo.add(cf, qualifier, valTwo);
     t.checkAndPut(row, cf, qualifier, valOne, pTwo);
-    t.flushCommits();
 
     Put pThree = new Put(row);
     pThree.add(cf, qualifier, valThree);
     t.checkAndPut(row, cf, qualifier, valOne, pThree);
-    t.flushCommits();
-
 
     metricsRegionServer.getRegionServerWrapper().forceRecompute();
     metricsHelper.assertCounter("checkMutateFailedCount", 1, serverSource);
@@ -289,7 +283,6 @@ public class TestRegionServerMetrics {
     Put p = new Put(row);
     p.add(cf, qualifier, val);
     t.put(p);
-    t.flushCommits();
 
     for(int count = 0; count< 13; count++) {
       Increment inc = new Increment(row);
@@ -297,8 +290,6 @@ public class TestRegionServerMetrics {
       t.increment(inc);
     }
 
-    t.flushCommits();
-
     metricsRegionServer.getRegionServerWrapper().forceRecompute();
     metricsHelper.assertCounter("incrementNumOps", 13, serverSource);
 
@@ -321,7 +312,6 @@ public class TestRegionServerMetrics {
     Put p = new Put(row);
     p.add(cf, qualifier, val);
     t.put(p);
-    t.flushCommits();
 
     for(int count = 0; count< 73; count++) {
       Append append = new Append(row);
@@ -329,8 +319,6 @@ public class TestRegionServerMetrics {
       t.append(append);
     }
 
-    t.flushCommits();
-
     metricsRegionServer.getRegionServerWrapper().forceRecompute();
     metricsHelper.assertCounter("appendNumOps", 73, serverSource);
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/2452d386/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSmallTests.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSmallTests.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSmallTests.java
index 4377082..9a3b581 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSmallTests.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSmallTests.java
@@ -23,6 +23,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 
@@ -245,15 +246,14 @@ public class TestReplicationSmallTests extends TestReplicationBase {
   @Test(timeout=300000)
   public void testSmallBatch() throws Exception {
     LOG.info("testSmallBatch");
-    Put put;
     // normal Batch tests
-    htable1.setAutoFlushTo(false);
+    List<Put> puts = new ArrayList<>();
     for (int i = 0; i < NB_ROWS_IN_BATCH; i++) {
-      put = new Put(Bytes.toBytes(i));
+      Put put = new Put(Bytes.toBytes(i));
       put.add(famName, row, row);
-      htable1.put(put);
+      puts.add(put);
     }
-    htable1.flushCommits();
+    htable1.put(puts);
 
     Scan scan = new Scan();
 
@@ -386,14 +386,16 @@ public class TestReplicationSmallTests extends TestReplicationBase {
   @Test(timeout=300000)
   public void testLoading() throws Exception {
     LOG.info("Writing out rows to table1 in testLoading");
-    htable1.setWriteBufferSize(1024);
-    ((HTable)htable1).setAutoFlushTo(false);
+    List<Put> puts = new ArrayList<Put>();
     for (int i = 0; i < NB_ROWS_IN_BIG_BATCH; i++) {
       Put put = new Put(Bytes.toBytes(i));
       put.add(famName, row, row);
-      htable1.put(put);
+      puts.add(put);
     }
-    htable1.flushCommits();
+    htable1.setWriteBufferSize(1024);
+    // The puts will be iterated through and flushed only when the buffer
+    // size is reached.
+    htable1.put(puts);
 
     Scan scan = new Scan();
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/2452d386/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabels.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabels.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabels.java
index 8684531..455d632 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabels.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabels.java
@@ -895,24 +895,15 @@ public abstract class TestVisibilityLabels {
 
   static Table createTableAndWriteDataWithLabels(TableName tableName, String... labelExps)
       throws Exception {
-    Table table = null;
-    try {
-      table = TEST_UTIL.createTable(tableName, fam);
-      int i = 1;
-      List<Put> puts = new ArrayList<Put>();
-      for (String labelExp : labelExps) {
-        Put put = new Put(Bytes.toBytes("row" + i));
-        put.add(fam, qual, HConstants.LATEST_TIMESTAMP, value);
-        put.setCellVisibility(new CellVisibility(labelExp));
-        puts.add(put);
-        i++;
-      }
-      table.put(puts);
-    } finally {
-      if (table != null) {
-        table.flushCommits();
-      }
+    List<Put> puts = new ArrayList<Put>();
+    for (int i = 0; i < labelExps.length; i++) {
+      Put put = new Put(Bytes.toBytes("row" + (i+1)));
+      put.add(fam, qual, HConstants.LATEST_TIMESTAMP, value);
+      put.setCellVisibility(new CellVisibility(labelExps[i]));
+      puts.add(put);
     }
+    Table table = TEST_UTIL.createTable(tableName, fam);
+    table.put(puts);
     return table;
   }