virajjasani commented on a change in pull request #1839:
URL: https://github.com/apache/hbase/pull/1839#discussion_r434406124



##########
File path: 
hbase-client/src/main/java/org/apache/hadoop/hbase/client/RawAsyncHBaseAdmin.java
##########
@@ -3521,20 +3522,33 @@ private void getProcedureResult(long procId, 
CompletableFuture<Void> future, int
       return failedFuture(e);
     }
     CompletableFuture<Void> future = new CompletableFuture<>();
-    addListener(ConnectionFactory.createAsyncConnection(peerConf), (conn, err) 
-> {
+    CompletableFuture<AsyncConnection> cf = 
ConnectionFactory.createAsyncConnection(peerConf);
+    addListener(cf, (conn, err) -> {
       if (err != null) {
-        future.completeExceptionally(err);
+        try {
+          future.completeExceptionally(err);
+        } finally {
+          IOUtils.closeQuietly(conn);

Review comment:
       Something similar to this might help avoid closing conn at each step:
   
   ```
   .............
       CompletableFuture<Void> future = new CompletableFuture<>();
       CompletableFuture<AsyncConnection> asyncConnection =
         ConnectionFactory.createAsyncConnection(peerConf);
       addListener(asyncConnection, (conn, err) -> {
         future.whenComplete((resp, error) -> {
           try {
             Closeables.close(conn, true);
           } catch (IOException e) {
             throw new AssertionError("IOException should not be thrown for 
swallowIOException=true");
           }
         });
         if (err != null) {
           future.completeExceptionally(err);
           return;
         }
   .............
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to