diff options
author | laszlocsomor <laszlocsomor@google.com> | 2018-07-10 06:14:49 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-07-10 06:15:52 -0700 |
commit | dda5bcedea18009a26adbb2dd01c82a7edfe9917 (patch) | |
tree | c86c1e0c8588d133eb2d1a77597da0df0b5bd5bd /src/main/java/com/google/devtools/build/lib/exec | |
parent | 9c883bf10568b818c7b5f8e80b19ba305e49206e (diff) |
Bazel server, VFS: revert to using asByteSource
commit 59f17d6e0550bf63a0b6ef182e2d63474e058ede updated files to use
try-with-resources when dealing with streams.
The change also got rid of asByteSource, replacing
it with throw-away ByteSource instances wrapping a
try-with-resources-guarded InputStream. Doing so
was unnecessary though, because all ByteSource
methods (except for open[Buffered]InputStream)
close the stream. Thanks to @jbduncan to point
that out and explain in detail [1].
[1] see comment thread on https://github.com/bazelbuild/bazel/commit/59f17d6e0550bf63a0b6ef182e2d63474e058ede under `FilesetManifest.java`
RELNOTES: none
PiperOrigin-RevId: 203934830
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/exec')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/exec/FilesetManifest.java | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/exec/FilesetManifest.java b/src/main/java/com/google/devtools/build/lib/exec/FilesetManifest.java index 2a54103fde..c48674a913 100644 --- a/src/main/java/com/google/devtools/build/lib/exec/FilesetManifest.java +++ b/src/main/java/com/google/devtools/build/lib/exec/FilesetManifest.java @@ -15,14 +15,13 @@ package com.google.devtools.build.lib.exec; import static java.nio.charset.StandardCharsets.UTF_8; -import com.google.common.io.ByteSource; import com.google.common.io.LineProcessor; import com.google.devtools.build.lib.actions.FilesetOutputSymlink; import com.google.devtools.build.lib.analysis.AnalysisUtils; +import com.google.devtools.build.lib.vfs.FileSystemUtils; import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.lib.vfs.PathFragment; import java.io.IOException; -import java.io.InputStream; import java.util.Collections; import java.util.HashMap; import java.util.LinkedHashMap; @@ -60,13 +59,8 @@ public final class FilesetManifest { RelativeSymlinkBehavior relSymlinkBehavior) throws IOException { Path file = execRoot.getRelative(AnalysisUtils.getManifestPathFromFilesetPath(manifest)); - try (InputStream in = file.getInputStream()) { - return new ByteSource() { - @Override - public InputStream openStream() throws IOException { - return in; - } - }.asCharSource(UTF_8) + try { + return FileSystemUtils.asByteSource(file).asCharSource(UTF_8) .readLines( new ManifestLineProcessor(workspaceName, manifest, relSymlinkBehavior)); } catch (IllegalStateException e) { |