Fixing resource leak where the input stream for a symlinked file was not closed when the logical file was removed.
Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/ba12672c Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/ba12672c Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/ba12672c Branch: refs/heads/master Commit: ba12672c57398ccaffab3ffc369357669e2142eb Parents: 09e4068 Author: Aaron McCurry <[email protected]> Authored: Mon Apr 6 06:40:28 2015 -0400 Committer: Aaron McCurry <[email protected]> Committed: Mon Apr 6 06:40:28 2015 -0400 ---------------------------------------------------------------------- .../src/main/java/org/apache/blur/store/hdfs/HdfsDirectory.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/ba12672c/blur-store/src/main/java/org/apache/blur/store/hdfs/HdfsDirectory.java ---------------------------------------------------------------------- diff --git a/blur-store/src/main/java/org/apache/blur/store/hdfs/HdfsDirectory.java b/blur-store/src/main/java/org/apache/blur/store/hdfs/HdfsDirectory.java index 7f695e3..f663251 100644 --- a/blur-store/src/main/java/org/apache/blur/store/hdfs/HdfsDirectory.java +++ b/blur-store/src/main/java/org/apache/blur/store/hdfs/HdfsDirectory.java @@ -412,7 +412,7 @@ public class HdfsDirectory extends Directory implements LastModified, HdfsSymlin } protected void delete(String name) throws IOException { - Path path = getPathOrSymlinkForDelete(name); + Path path = getPath(); FSDataInputRandomAccess inputStream = _inputMap.remove(path); Tracer trace = Trace.trace("filesystem - delete", Trace.param("path", path)); if (inputStream != null) { @@ -423,7 +423,8 @@ public class HdfsDirectory extends Directory implements LastModified, HdfsSymlin _symlinkPathMap.remove(name); } try { - _fileSystem.delete(path, true); + Path symlinkPath = getPathOrSymlinkForDelete(name); + _fileSystem.delete(symlinkPath, true); } finally { trace.done(); }
