Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 13A87200C6B for ; Mon, 17 Apr 2017 22:54:50 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 12A18160BAB; Mon, 17 Apr 2017 20:54:50 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 68979160BB1 for ; Mon, 17 Apr 2017 22:54:49 +0200 (CEST) Received: (qmail 68373 invoked by uid 500); 17 Apr 2017 20:54:42 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 66462 invoked by uid 99); 17 Apr 2017 20:54:41 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Apr 2017 20:54:41 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 9E757E00C5; Mon, 17 Apr 2017 20:54:41 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: syuanjiang@apache.org To: commits@hbase.apache.org Date: Mon, 17 Apr 2017 20:55:25 -0000 Message-Id: In-Reply-To: <483d8d5c2cff43648a0e9f5cdc603bbb@git.apache.org> References: <483d8d5c2cff43648a0e9f5cdc603bbb@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [46/50] [abbrv] hbase git commit: HBASE-16875 Changed try-with-resources in the docs to recommended way archived-at: Mon, 17 Apr 2017 20:54:50 -0000 HBASE-16875 Changed try-with-resources in the docs to recommended way Signed-off-by: Chia-Ping Tsai Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/c8cd921b Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/c8cd921b Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/c8cd921b Branch: refs/heads/hbase-12439 Commit: c8cd921bededa67b2b0de823005830d750534d93 Parents: c1ac3f7 Author: Jan Hentschel Authored: Sat Mar 4 10:04:02 2017 +0100 Committer: Chia-Ping Tsai Committed: Mon Apr 17 10:59:46 2017 +0800 ---------------------------------------------------------------------- src/main/asciidoc/_chapters/architecture.adoc | 7 +++--- src/main/asciidoc/_chapters/security.adoc | 29 ++++++++-------------- 2 files changed, 13 insertions(+), 23 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/c8cd921b/src/main/asciidoc/_chapters/architecture.adoc ---------------------------------------------------------------------- diff --git a/src/main/asciidoc/_chapters/architecture.adoc b/src/main/asciidoc/_chapters/architecture.adoc index 27aebd9..7f9ba07 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 } ---- ==== http://git-wip-us.apache.org/repos/asf/hbase/blob/c8cd921b/src/main/asciidoc/_chapters/security.adoc ---------------------------------------------------------------------- diff --git a/src/main/asciidoc/_chapters/security.adoc b/src/main/asciidoc/_chapters/security.adoc index 0ed9ba2..ccb5adb 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; } - } + }); } ----