hbase-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chia-Ping Tsai (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HBASE-16875) Cleanup docs' use of try-with-resources
Date Thu, 13 Apr 2017 16:22:41 GMT

    [ https://issues.apache.org/jira/browse/HBASE-16875?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15967826#comment-15967826
] 

Chia-Ping Tsai commented on HBASE-16875:
----------------------------------------

{noformat}
@@ -1016,19 +1015,18 @@ public static void grantOnTable(final HBaseTestingUtility util, final
String use
     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(conf);
+           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;
       }
     }
   }
{noformat}
These sample code is incorrect. Please take a look at the SecureTestUtil#grantOnTable.


> Cleanup docs' use of try-with-resources
> ---------------------------------------
>
>                 Key: HBASE-16875
>                 URL: https://issues.apache.org/jira/browse/HBASE-16875
>             Project: HBase
>          Issue Type: Bug
>          Components: documentation
>            Reporter: Dima Spivak
>            Assignee: Jan Hentschel
>            Priority: Trivial
>              Labels: beginner
>         Attachments: HBASE-16875.master.001.patch, HBASE-16875.master.002.patch
>
>
> In a [number|https://github.com/apache/hbase/blame/bb3d9ccd489fb64e3cb2020583935a393382a678/src/main/asciidoc/_chapters/security.adoc#L205-L206]
[of|https://github.com/apache/hbase/blame/bb3d9ccd489fb64e3cb2020583935a393382a678/src/main/asciidoc/_chapters/security.adoc#L1019-L1020]
[places|https://github.com/apache/hbase/blame/bb3d9ccd489fb64e3cb2020583935a393382a678/src/main/asciidoc/_chapters/architecture.adoc#L222-L223],
we show examples that lend themselves to using Java 7's try-with-resources statement, but
we use the statement in a less-than-ideal nested way. Let's change our docs throughout to
do it [the recommended way|https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html].



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message