flume-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hshreedha...@apache.org
Subject git commit: FLUME-1820. Should not be possible for RPC client to block indefinitely on close()
Date Fri, 04 Jan 2013 19:30:10 GMT
Updated Branches:
  refs/heads/flume-1.4 977f1faf9 -> 4d9ef89ca


FLUME-1820. Should not be possible for RPC client to block indefinitely on close()

(Mike Percy via Hari Shreedharan)


Project: http://git-wip-us.apache.org/repos/asf/flume/repo
Commit: http://git-wip-us.apache.org/repos/asf/flume/commit/4d9ef89c
Tree: http://git-wip-us.apache.org/repos/asf/flume/tree/4d9ef89c
Diff: http://git-wip-us.apache.org/repos/asf/flume/diff/4d9ef89c

Branch: refs/heads/flume-1.4
Commit: 4d9ef89ca0a9d91da1330b041c985a18c5a943ed
Parents: 977f1fa
Author: Hari Shreedharan <harishreedharan@gmail.com>
Authored: Fri Jan 4 11:28:29 2013 -0800
Committer: Hari Shreedharan <harishreedharan@gmail.com>
Committed: Fri Jan 4 11:29:43 2013 -0800

----------------------------------------------------------------------
 .../org/apache/flume/api/NettyAvroRpcClient.java   |   23 +++++++++-----
 1 files changed, 15 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flume/blob/4d9ef89c/flume-ng-sdk/src/main/java/org/apache/flume/api/NettyAvroRpcClient.java
----------------------------------------------------------------------
diff --git a/flume-ng-sdk/src/main/java/org/apache/flume/api/NettyAvroRpcClient.java b/flume-ng-sdk/src/main/java/org/apache/flume/api/NettyAvroRpcClient.java
index bd116ff..cf9724c 100644
--- a/flume-ng-sdk/src/main/java/org/apache/flume/api/NettyAvroRpcClient.java
+++ b/flume-ng-sdk/src/main/java/org/apache/flume/api/NettyAvroRpcClient.java
@@ -124,17 +124,24 @@ implements RpcClient {
   public void close() throws FlumeException {
     if (callTimeoutPool != null) {
       callTimeoutPool.shutdown();
-      while (!callTimeoutPool.isTerminated()) {
-        try {
-          callTimeoutPool.awaitTermination(requestTimeout,
-              TimeUnit.MILLISECONDS);
-        } catch (InterruptedException ex) {
-          logger.warn(this + ": Interrupted during close", ex);
+      try {
+        if (!callTimeoutPool.awaitTermination(requestTimeout,
+            TimeUnit.MILLISECONDS)) {
           callTimeoutPool.shutdownNow();
-          Thread.currentThread().interrupt();
-          break;
+          if (!callTimeoutPool.awaitTermination(requestTimeout,
+              TimeUnit.MILLISECONDS)) {
+            logger.warn(this + ": Unable to cleanly shut down call timeout " +
+                "pool");
+          }
         }
+      } catch (InterruptedException ex) {
+        logger.warn(this + ": Interrupted during close", ex);
+        // re-cancel if current thread also interrupted
+        callTimeoutPool.shutdownNow();
+        // preserve interrupt status
+        Thread.currentThread().interrupt();
       }
+
       callTimeoutPool = null;
     }
     try {


Mime
View raw message