diff options
author | Miguel Alcon Pinto <malcon@google.com> | 2015-11-04 17:36:02 +0000 |
---|---|---|
committer | John Field <jfield@google.com> | 2015-11-05 16:49:27 +0000 |
commit | 53fb4d0ef10dea9d58f4b17f08c59c8e81ebc09a (patch) | |
tree | 38ab19ff52f325ce6fa33d7e4e925c9c4fb89c7d /src/main/java/com/google/devtools/build/lib/vfs/FileSystem.java | |
parent | 5c67934f08c821af6fbf0eab422caed805d77ee4 (diff) |
Close some streams that we didn't
--
MOS_MIGRATED_REVID=107048547
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/vfs/FileSystem.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/vfs/FileSystem.java | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/vfs/FileSystem.java b/src/main/java/com/google/devtools/build/lib/vfs/FileSystem.java index d396139cfe..55d49ed89c 100644 --- a/src/main/java/com/google/devtools/build/lib/vfs/FileSystem.java +++ b/src/main/java/com/google/devtools/build/lib/vfs/FileSystem.java @@ -142,18 +142,20 @@ public abstract class FileSystem { try { Path canonicalPath = path.resolveSymbolicLinks(); Path mountTable = path.getRelative("/proc/mounts"); - for (String line : CharStreams.readLines(new InputStreamReader(mountTable.getInputStream(), - ISO_8859_1))) { - String[] words = line.split("\\s+"); - if (words.length >= 3) { - if (!words[1].startsWith("/")) { - continue; - } - Path mountPoint = path.getFileSystem().getPath(words[1]); - int segmentCount = mountPoint.asFragment().segmentCount(); - if (canonicalPath.startsWith(mountPoint) && segmentCount > bestMountPointSegmentCount) { - bestMountPointSegmentCount = segmentCount; - fileSystem = words[2]; + try (InputStreamReader reader = new InputStreamReader(mountTable.getInputStream(), + ISO_8859_1)) { + for (String line : CharStreams.readLines(reader)) { + String[] words = line.split("\\s+"); + if (words.length >= 3) { + if (!words[1].startsWith("/")) { + continue; + } + Path mountPoint = path.getFileSystem().getPath(words[1]); + int segmentCount = mountPoint.asFragment().segmentCount(); + if (canonicalPath.startsWith(mountPoint) && segmentCount > bestMountPointSegmentCount) { + bestMountPointSegmentCount = segmentCount; + fileSystem = words[2]; + } } } } |