From abe9c4ee031d34814da18acb6ea16307d30a4a3e Mon Sep 17 00:00:00 2001 From: Tsz-wo Sze Date: Wed, 26 Feb 2014 19:57:16 +0000 Subject: [PATCH] HADOOP-10368. InputStream is not closed in VersionInfo ctor. Contributed by Tsuyoshi OZAWA git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1572220 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-common-project/hadoop-common/CHANGES.txt | 3 +++ .../main/java/org/apache/hadoop/util/VersionInfo.java | 10 +++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 94c47f1d2d3..22f0bc5c294 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -378,6 +378,9 @@ Release 2.4.0 - UNRELEASED HADOOP-10070. RPC client doesn't use per-connection conf to determine server's expected Kerberos principal name. (atm) + HADOOP-10368. InputStream is not closed in VersionInfo ctor. + (Tsuyoshi OZAWA via szetszwo) + BREAKDOWN OF HADOOP-10184 SUBTASKS AND RELATED JIRAS HADOOP-10185. FileSystem API for ACLs. (cnauroth) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/VersionInfo.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/VersionInfo.java index 1547577b864..1768567bd66 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/VersionInfo.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/VersionInfo.java @@ -31,6 +31,7 @@ import org.apache.hadoop.classification.InterfaceStability; import java.io.IOException; import java.io.InputStream; import java.util.Properties; +import org.apache.hadoop.io.IOUtils; /** * This class returns build information about Hadoop components. @@ -45,16 +46,19 @@ public class VersionInfo { protected VersionInfo(String component) { info = new Properties(); String versionInfoFile = component + "-version-info.properties"; + InputStream is = null; try { - InputStream is = Thread.currentThread().getContextClassLoader() + is = Thread.currentThread().getContextClassLoader() .getResourceAsStream(versionInfoFile); if (is == null) { throw new IOException("Resource not found"); } info.load(is); } catch (IOException ex) { - LogFactory.getLog(getClass()).warn("Could not read '" + - versionInfoFile + "', " + ex.toString(), ex); + LogFactory.getLog(getClass()).warn("Could not read '" + + versionInfoFile + "', " + ex.toString(), ex); + } finally { + IOUtils.closeStream(is); } }