hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shahr...@apache.org
Subject hadoop git commit: HADOOP-14841 Kms client should disconnect if unable to get output stream from connection. Contributed by Rushabh S Shah
Date Fri, 04 May 2018 21:06:28 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2.8 26d140d62 -> 1fec21f85


HADOOP-14841 Kms client should disconnect if unable to get output stream from connection.
Contributed by Rushabh S Shah

(cherry picked from commit 4cdbdce752e192b45c2b9756c2d4bd24ceffdabd)


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

Branch: refs/heads/branch-2.8
Commit: 1fec21f8504093e157195a93c5661e0b58b5a4bc
Parents: 26d140d
Author: Rushabh Shah <shahrs87@apache.org>
Authored: Fri May 4 15:36:13 2018 -0500
Committer: Rushabh Shah <shahrs87@apache.org>
Committed: Fri May 4 16:03:11 2018 -0500

----------------------------------------------------------------------
 .../hadoop/crypto/key/kms/KMSClientProvider.java       | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/1fec21f8/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/key/kms/KMSClientProvider.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/key/kms/KMSClientProvider.java
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/key/kms/KMSClientProvider.java
index 59ec9cc..bd951f4 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/key/kms/KMSClientProvider.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/key/kms/KMSClientProvider.java
@@ -519,12 +519,21 @@ public class KMSClientProvider extends KeyProvider implements CryptoExtension,
       int expectedResponse, Class<T> klass, int authRetryCount)
       throws IOException {
     T ret = null;
+    OutputStream os = null;
     try {
       if (jsonOutput != null) {
-        writeJson(jsonOutput, conn.getOutputStream());
+        os = conn.getOutputStream();
+        writeJson(jsonOutput, os);
       }
     } catch (IOException ex) {
-      IOUtils.closeStream(conn.getInputStream());
+      // The payload is not serialized if getOutputStream fails.
+      // Calling getInputStream will issue the put/post request with no payload
+      // which causes HTTP 500 server error.
+      if (os == null) {
+        conn.disconnect();
+      } else {
+        IOUtils.closeStream(conn.getInputStream());
+      }
       throw ex;
     }
     if ((conn.getResponseCode() == HttpURLConnection.HTTP_FORBIDDEN


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message