diff --git a/src/main/asciidoc/_chapters/architecture.adoc b/src/main/asciidoc/_chapters/architecture.adoc index 27aebd9fef1..7f9ba07e788 100644 --- a/src/main/asciidoc/_chapters/architecture.adoc +++ b/src/main/asciidoc/_chapters/architecture.adoc @@ -219,10 +219,9 @@ For applications which require high-end multithreaded access (e.g., web-servers ---- // Create a connection to the cluster. Configuration conf = HBaseConfiguration.create(); -try (Connection connection = ConnectionFactory.createConnection(conf)) { - try (Table table = connection.getTable(TableName.valueOf(tablename)) { - // use table as needed, the table returned is lightweight - } +try (Connection connection = ConnectionFactory.createConnection(conf); + Table table = connection.getTable(TableName.valueOf(tablename))) { + // use table as needed, the table returned is lightweight } ---- ==== diff --git a/src/main/asciidoc/_chapters/security.adoc b/src/main/asciidoc/_chapters/security.adoc index 0ed9ba218ee..ccb5adb1284 100644 --- a/src/main/asciidoc/_chapters/security.adoc +++ b/src/main/asciidoc/_chapters/security.adoc @@ -202,10 +202,9 @@ Set it in the `Configuration` supplied to `Table`: Configuration conf = HBaseConfiguration.create(); Connection connection = ConnectionFactory.createConnection(conf); conf.set("hbase.rpc.protection", "privacy"); -try (Connection connection = ConnectionFactory.createConnection(conf)) { - try (Table table = connection.getTable(TableName.valueOf(tablename)) { +try (Connection connection = ConnectionFactory.createConnection(conf); + Table table = connection.getTable(TableName.valueOf(tablename))) { .... do your stuff - } } ---- @@ -1014,24 +1013,16 @@ public static void grantOnTable(final HBaseTestingUtility util, final String use SecureTestUtil.updateACLs(util, new Callable() { @Override public Void call() throws Exception { - Configuration conf = HBaseConfiguration.create(); - Connection connection = ConnectionFactory.createConnection(conf); - try (Connection connection = ConnectionFactory.createConnection(conf)) { - try (Table table = connection.getTable(TableName.valueOf(tablename)) { - AccessControlLists.ACL_TABLE_NAME); - try { - BlockingRpcChannel service = acl.coprocessorService(HConstants.EMPTY_START_ROW); - AccessControlService.BlockingInterface protocol = - AccessControlService.newBlockingStub(service); - ProtobufUtil.grant(protocol, user, table, family, qualifier, actions); - } finally { - acl.close(); - } - return null; - } + try (Connection connection = ConnectionFactory.createConnection(util.getConfiguration()); + Table acl = connection.getTable(AccessControlLists.ACL_TABLE_NAME)) { + BlockingRpcChannel service = acl.coprocessorService(HConstants.EMPTY_START_ROW); + AccessControlService.BlockingInterface protocol = + AccessControlService.newBlockingStub(service); + AccessControlUtil.grant(null, protocol, user, table, family, qualifier, false, actions); } + return null; } - } + }); } ----