Index: ql/src/java/org/apache/hadoop/hive/ql/io/SymbolicInputFormat.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/io/SymbolicInputFormat.java (revision 1405070) +++ ql/src/java/org/apache/hadoop/hive/ql/io/SymbolicInputFormat.java (working copy) @@ -63,17 +63,22 @@ toRemovePaths.add(path); ArrayList aliases = pathToAliases.remove(path); for (FileStatus symlink : symlinks) { - BufferedReader reader = new BufferedReader(new InputStreamReader( - fileSystem.open(symlink.getPath()))); + BufferedReader reader = null; + try { + reader = new BufferedReader(new InputStreamReader( + fileSystem.open(symlink.getPath()))); - partDesc.setInputFileFormatClass(TextInputFormat.class); + partDesc.setInputFileFormatClass(TextInputFormat.class); - String line; - while ((line = reader.readLine()) != null) { - // no check for the line? How to check? - // if the line is invalid for any reason, the job will fail. - toAddPathToPart.put(line, partDesc); - pathToAliases.put(line, aliases); + String line; + while ((line = reader.readLine()) != null) { + // no check for the line? How to check? + // if the line is invalid for any reason, the job will fail. + toAddPathToPart.put(line, partDesc); + pathToAliases.put(line, aliases); + } + } finally { + org.apache.hadoop.io.IOUtils.closeStream(reader); } } } Index: ql/src/java/org/apache/hadoop/hive/ql/io/SymlinkTextInputFormat.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/io/SymlinkTextInputFormat.java (revision 1405070) +++ ql/src/java/org/apache/hadoop/hive/ql/io/SymlinkTextInputFormat.java (working copy) @@ -196,15 +196,18 @@ // Read paths from each symlink file. for (FileStatus symlink : symlinks) { - BufferedReader reader = - new BufferedReader( - new InputStreamReader( - fileSystem.open(symlink.getPath()))); - - String line; - while ((line = reader.readLine()) != null) { - targetPaths.add(new Path(line)); - symlinkPaths.add(symlink.getPath()); + BufferedReader reader = null; + try { + reader = new BufferedReader( + new InputStreamReader( + fileSystem.open(symlink.getPath()))); + String line; + while ((line = reader.readLine()) != null) { + targetPaths.add(new Path(line)); + symlinkPaths.add(symlink.getPath()); + } + } finally { + org.apache.hadoop.io.IOUtils.closeStream(reader); } } } Index: ql/src/test/org/apache/hadoop/hive/ql/io/TestSymlinkTextInputFormat.java =================================================================== --- ql/src/test/org/apache/hadoop/hive/ql/io/TestSymlinkTextInputFormat.java (revision 1405070) +++ ql/src/test/org/apache/hadoop/hive/ql/io/TestSymlinkTextInputFormat.java (working copy) @@ -154,6 +154,7 @@ + " failed with exit code= " + ecode); } + tblCreated = true; String loadFileCommand = "LOAD DATA LOCAL INPATH '" + new Path(symlinkDir, "symlink_file").toString() + "' INTO TABLE " + tblName; @@ -263,6 +264,7 @@ while (reader.next(key, value)) { received.add(value.toString()); } + reader.close(); } List expected = new ArrayList(); @@ -307,6 +309,7 @@ while (reader.next(key, value)) { received.add(value.toString()); } + reader.close(); } List expected = new ArrayList();