diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 1a53ee86b2..0b88ed050c 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -1028,6 +1028,9 @@ Release 2.8.0 - UNRELEASED HADOOP-12658. Clear javadoc and check style issues around DomainSocket (Kai Zheng via umamahesh) + HADOOP-12604. Exception may be swallowed in KMSClientProvider. + (Yongjun Zhang) + OPTIMIZATIONS HADOOP-11785. Reduce the number of listStatus operation in distcp 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 cbfa6f6e9a..fd7a83ebe1 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 @@ -27,6 +27,7 @@ import org.apache.hadoop.crypto.key.KeyProviderFactory; import org.apache.hadoop.fs.CommonConfigurationKeysPublic; import org.apache.hadoop.fs.Path; +import org.apache.hadoop.io.IOUtils; import org.apache.hadoop.io.Text; import org.apache.hadoop.security.Credentials; import org.apache.hadoop.security.ProviderUtils; @@ -515,7 +516,7 @@ private T call(HttpURLConnection conn, Map jsonOutput, writeJson(jsonOutput, conn.getOutputStream()); } } catch (IOException ex) { - conn.getInputStream().close(); + IOUtils.closeStream(conn.getInputStream()); throw ex; } if ((conn.getResponseCode() == HttpURLConnection.HTTP_FORBIDDEN @@ -555,15 +556,8 @@ private T call(HttpURLConnection conn, Map jsonOutput, try { is = conn.getInputStream(); ret = mapper.readValue(is, klass); - } catch (IOException ex) { - if (is != null) { - is.close(); - } - throw ex; } finally { - if (is != null) { - is.close(); - } + IOUtils.closeStream(is); } } return ret;