diff --git ql/src/java/org/apache/hadoop/hive/ql/io/SymbolicInputFormat.java ql/src/java/org/apache/hadoop/hive/ql/io/SymbolicInputFormat.java index 12f7b16..97dd161 100644 --- ql/src/java/org/apache/hadoop/hive/ql/io/SymbolicInputFormat.java +++ ql/src/java/org/apache/hadoop/hive/ql/io/SymbolicInputFormat.java @@ -63,18 +63,26 @@ public class SymbolicInputFormat implements ReworkMapredInputFormat { 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); + } + }catch(IOException te){ + throw te; + + }finally{ + reader.close(); + } } } } diff --git ql/src/java/org/apache/hadoop/hive/ql/io/SymlinkTextInputFormat.java ql/src/java/org/apache/hadoop/hive/ql/io/SymlinkTextInputFormat.java index fbbf057..2fc9a8c 100644 --- ql/src/java/org/apache/hadoop/hive/ql/io/SymlinkTextInputFormat.java +++ ql/src/java/org/apache/hadoop/hive/ql/io/SymlinkTextInputFormat.java @@ -196,15 +196,22 @@ public class SymlinkTextInputFormat extends SymbolicInputFormat implements // Read paths from each symlink file. for (FileStatus symlink : symlinks) { - BufferedReader reader = + 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()); + String line; + while ((line = reader.readLine()) != null) { + targetPaths.add(new Path(line)); + symlinkPaths.add(symlink.getPath()); + } + }catch(IOException te){ + throw te; + }finally{ + reader.close(); } } }