浏览代码

HADOOP-11500. InputStream is left unclosed in ApplicationClassLoader. Contributed by Ted Yu.

Tsuyoshi Ozawa 10 年之前
父节点
当前提交
825923f7b9

+ 3 - 0
hadoop-common-project/hadoop-common/CHANGES.txt

@@ -744,6 +744,9 @@ Release 2.7.0 - UNRELEASED
     HADOOP-11209. Configuration#updatingResource/finalParameters are not
     thread-safe. (Varun Saxena via ozawa)
 
+    HADOOP-11500. InputStream is left unclosed in ApplicationClassLoader.
+    (Ted Yu via ozawa)
+
 Release 2.6.0 - 2014-11-18
 
   INCOMPATIBLE CHANGES

+ 2 - 4
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ApplicationClassLoader.java

@@ -67,10 +67,8 @@ public class ApplicationClassLoader extends URLClassLoader {
   };
 
   static {
-    InputStream is = null;
-    try {
-      is = ApplicationClassLoader.class.getClassLoader().
-          getResourceAsStream(PROPERTIES_FILE);
+    try (InputStream is = ApplicationClassLoader.class.getClassLoader()
+        .getResourceAsStream(PROPERTIES_FILE);) {
       if (is == null) {
         throw new ExceptionInInitializerError("properties file " +
             PROPERTIES_FILE + " is not found");