You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2018/09/30 03:53:36 UTC

[GitHub] sijie closed pull request #1717: [table service] [client] Provide a timeout mechanism on closing the client

sijie closed pull request #1717: [table service] [client] Provide a timeout mechanism on closing the client
URL: https://github.com/apache/bookkeeper/pull/1717
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/stream/clients/java/all/src/main/java/org/apache/bookkeeper/clients/StorageClientImpl.java b/stream/clients/java/all/src/main/java/org/apache/bookkeeper/clients/StorageClientImpl.java
index fca1e5a775..9d49556970 100644
--- a/stream/clients/java/all/src/main/java/org/apache/bookkeeper/clients/StorageClientImpl.java
+++ b/stream/clients/java/all/src/main/java/org/apache/bookkeeper/clients/StorageClientImpl.java
@@ -128,7 +128,11 @@ protected void closeAsyncOnce(CompletableFuture<Void> closeFuture) {
 
     @Override
     public void close() {
-        super.close();
+        try {
+            super.close(1, TimeUnit.SECONDS);
+        } catch (Exception e) {
+            log.warn("Encountered exceptions on closing the storage client", e);
+        }
         scheduler.forceShutdown(100, TimeUnit.MILLISECONDS);
     }
 }
diff --git a/stream/common/src/main/java/org/apache/bookkeeper/common/util/AutoAsyncCloseable.java b/stream/common/src/main/java/org/apache/bookkeeper/common/util/AutoAsyncCloseable.java
index d4fc82c9c1..febcd09c5c 100644
--- a/stream/common/src/main/java/org/apache/bookkeeper/common/util/AutoAsyncCloseable.java
+++ b/stream/common/src/main/java/org/apache/bookkeeper/common/util/AutoAsyncCloseable.java
@@ -18,6 +18,7 @@
 
 package org.apache.bookkeeper.common.util;
 
+import java.util.concurrent.TimeUnit;
 import org.apache.bookkeeper.common.concurrent.FutureUtils;
 
 /**
@@ -39,4 +40,8 @@ default void close() {
             // ignore the exception
         }
     }
+
+    default void close(long waitTimeout, TimeUnit waitTimeUnit) throws Exception {
+        FutureUtils.result(closeAsync(), waitTimeout, waitTimeUnit);
+    }
 }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services