You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@knox.apache.org by su...@apache.org on 2017/01/11 20:23:05 UTC

knox git commit: KNOX-806 Implement Closeable for deallocable resources (Vincent Devillers via Sumit Gupta)

Repository: knox
Updated Branches:
  refs/heads/master e2e39f3fa -> 869ced5de


KNOX-806 Implement Closeable for deallocable resources (Vincent Devillers via Sumit Gupta)


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

Branch: refs/heads/master
Commit: 869ced5de8b948965b58d2c4415bc1e383a89ba0
Parents: e2e39f3
Author: Sumit Gupta <su...@apache.org>
Authored: Wed Jan 11 15:21:16 2017 -0500
Committer: Sumit Gupta <su...@apache.org>
Committed: Wed Jan 11 15:21:16 2017 -0500

----------------------------------------------------------------------
 .../hadoop/gateway/shell/BasicResponse.java     | 21 ++++++++++----------
 .../org/apache/hadoop/gateway/shell/Hadoop.java | 12 ++++++++++-
 2 files changed, 22 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/869ced5d/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/BasicResponse.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/BasicResponse.java b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/BasicResponse.java
index afd59fd..9abb457 100644
--- a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/BasicResponse.java
+++ b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/BasicResponse.java
@@ -1,12 +1,3 @@
-package org.apache.hadoop.gateway.shell;
-
-import org.apache.http.HttpResponse;
-import org.apache.http.entity.ContentType;
-import org.apache.http.util.EntityUtils;
-
-import java.io.IOException;
-import java.io.InputStream;
-
 /**
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -24,7 +15,17 @@ import java.io.InputStream;
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-public class BasicResponse {
+package org.apache.hadoop.gateway.shell;
+
+import org.apache.http.HttpResponse;
+import org.apache.http.entity.ContentType;
+import org.apache.http.util.EntityUtils;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.io.InputStream;
+
+public class BasicResponse implements Closeable {
 
   private HttpResponse response;
   private boolean consumed = false;

http://git-wip-us.apache.org/repos/asf/knox/blob/869ced5d/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/Hadoop.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/Hadoop.java b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/Hadoop.java
index 651b061..2dd91f5 100644
--- a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/Hadoop.java
+++ b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/Hadoop.java
@@ -46,6 +46,7 @@ import org.apache.http.ssl.SSLContexts;
 
 import javax.net.ssl.HostnameVerifier;
 import javax.net.ssl.SSLContext;
+import java.io.Closeable;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
@@ -66,7 +67,7 @@ import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 
-public class Hadoop {
+public class Hadoop implements Closeable {
 
   private static final String GATEWAY_CLIENT_TRUST_DEFAULT_PASS = "changeit";
   private static final String KNOX_CLIENT_TRUSTSTORE_PASS = "KNOX_CLIENT_TRUSTSTORE_PASS";
@@ -271,4 +272,13 @@ public class Hadoop {
     executor.shutdown();
     return executor.awaitTermination( timeout, unit );
   }
+
+  @Override
+  public void close() throws IOException {
+    try {
+      shutdown();
+    } catch (InterruptedException e) {
+      throw new HadoopException("Can not shutdown underlying resources", e);
+    }
+  }
 }