diff options
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 | 14 |
1 files changed, 8 insertions, 6 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 8258dccfc0..01c016905f 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 @@ -268,12 +268,14 @@ public abstract class FileSystem { * @throws IOException if the digest could not be computed for any reason */ protected byte[] getDigest(final Path path, DigestHashFunction hashFunction) throws IOException { - return new ByteSource() { - @Override - public InputStream openStream() throws IOException { - return getInputStream(path); - } - }.hash(hashFunction.getHash()).asBytes(); + try (InputStream in = getInputStream(path)) { + return new ByteSource() { + @Override + public InputStream openStream() throws IOException { + return in; + } + }.hash(hashFunction.getHash()).asBytes(); + } } /** |