소스 검색

HADOOP-10223. MiniKdc#main() should close the FileReader it creates. (Ted Yu via tucu)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1557627 13f79535-47bb-0310-9956-ffa450edef68
Alejandro Abdelnur 11 년 전
부모
커밋
bc2a443418

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

@@ -511,6 +511,9 @@ Release 2.4.0 - UNRELEASED
     HADOOP-10214. Fix multithreaded correctness warnings in ActiveStandbyElector
     (Liang Xie via kasha)
 
+    HADOOP-10223. MiniKdc#main() should close the FileReader it creates. 
+    (Ted Yu via tucu)
+
 Release 2.3.0 - UNRELEASED
 
   INCOMPATIBLE CHANGES

+ 9 - 1
hadoop-common-project/hadoop-minikdc/src/main/java/org/apache/hadoop/minikdc/MiniKdc.java

@@ -125,7 +125,15 @@ public class MiniKdc {
               + file.getAbsolutePath());
     }
     Properties userConf = new Properties();
-    userConf.load(new FileReader(file));
+    FileReader r = null;
+    try {
+      r = new FileReader(file);
+      userConf.load(r);
+    } finally {
+      if (r != null) {
+        r.close();
+      }
+    }
     for (Map.Entry entry : userConf.entrySet()) {
       conf.put(entry.getKey(), entry.getValue());
     }