Browse Source

MAPREDUCE-6045. need close the DataInputStream after open it in TestMapReduce.java (zxu via rkanter)

(cherry picked from commit d9e4d67d18811e16d5b0a76ea8228d333ded195f)
Robert Kanter 10 years ago
parent
commit
22b38cf29a

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

@@ -55,6 +55,9 @@ Release 2.7.0 - UNRELEASED
     MAPREDUCE-6166. Reducers do not validate checksum of map outputs when
     fetching directly to disk. (Eric Payne via gera)
 
+    MAPREDUCE-6045. need close the DataInputStream after open it in
+    TestMapReduce.java (zxu via rkanter)
+
 Release 2.6.0 - 2014-11-18
 
   INCOMPATIBLE CHANGES

+ 8 - 4
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/TestMapReduce.java

@@ -465,11 +465,15 @@ public class TestMapReduce {
   private static boolean isSequenceFile(FileSystem fs,
                                         Path f) throws IOException {
     DataInputStream in = fs.open(f);
-    byte[] seq = "SEQ".getBytes();
-    for(int i=0; i < seq.length; ++i) {
-      if (seq[i] != in.read()) {
-        return false;
+    try {
+      byte[] seq = "SEQ".getBytes();
+      for (int i = 0; i < seq.length; ++i) {
+        if (seq[i] != in.read()) {
+          return false;
+        }
       }
+    } finally {
+      in.close();
     }
     return true;
   }