knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kris...@apache.org
Subject knox git commit: KNOX-720 - Knox DSL - Ensure that HTTP client is closed on shutdown
Date Wed, 26 Sep 2018 14:50:54 GMT
Repository: knox
Updated Branches:
  refs/heads/master 8dc4495a7 -> a66a78cb6


KNOX-720 - Knox DSL - Ensure that HTTP client is closed on shutdown

Signed-off-by: Kevin Risden <krisden@apache.org>


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

Branch: refs/heads/master
Commit: a66a78cb6ff308b821fbfcdfd94eff14b6cc23eb
Parents: 8dc4495
Author: Kevin Risden <krisden@apache.org>
Authored: Tue Sep 25 10:36:43 2018 -0400
Committer: Kevin Risden <krisden@apache.org>
Committed: Wed Sep 26 09:51:59 2018 -0400

----------------------------------------------------------------------
 .../org/apache/knox/gateway/shell/Hadoop.java   | 26 ++++++++++++++------
 1 file changed, 19 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/a66a78cb/gateway-shell/src/main/java/org/apache/knox/gateway/shell/Hadoop.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/Hadoop.java b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/Hadoop.java
index bc1077c..9d8c821 100644
--- a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/Hadoop.java
+++ b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/Hadoop.java
@@ -285,13 +285,27 @@ public class Hadoop implements Closeable {
     }
   }
 
-  public void shutdown() throws InterruptedException {
-    executor.shutdownNow();
+  private void closeClient() throws IOException {
+    if(client != null) {
+      client.close();
+    }
   }
 
-  public boolean shutdown( long timeout, TimeUnit unit ) throws InterruptedException {
-    executor.shutdown();
-    return executor.awaitTermination( timeout, unit );
+  public void shutdown() throws InterruptedException, IOException {
+    try {
+      executor.shutdownNow();
+    } finally {
+      closeClient();
+    }
+  }
+
+  public boolean shutdown( long timeout, TimeUnit unit ) throws InterruptedException, IOException
{
+    try{
+      executor.shutdown();
+      return executor.awaitTermination( timeout, unit );
+    } finally {
+      closeClient();
+    }
   }
 
   @Override
@@ -300,8 +314,6 @@ public class Hadoop implements Closeable {
       shutdown();
     } catch (InterruptedException e) {
       throw new HadoopException("Can not shutdown underlying resources", e);
-    } finally {
-      client.close();
     }
   }
 }


Mime
View raw message