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/test/java/com/google/devtools/build/skydoc | |
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/test/java/com/google/devtools/build/skydoc')
-rw-r--r-- | src/test/java/com/google/devtools/build/skydoc/SkydocTest.java | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/src/test/java/com/google/devtools/build/skydoc/SkydocTest.java b/src/test/java/com/google/devtools/build/skydoc/SkydocTest.java index a1d7acbe29..89327e3f26 100644 --- a/src/test/java/com/google/devtools/build/skydoc/SkydocTest.java +++ b/src/test/java/com/google/devtools/build/skydoc/SkydocTest.java @@ -20,13 +20,12 @@ import static com.google.devtools.build.lib.testutil.MoreAsserts.assertThrows; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; -import com.google.common.io.ByteSource; import com.google.devtools.build.lib.skylark.util.SkylarkTestCase; import com.google.devtools.build.lib.syntax.ParserInputSource; +import com.google.devtools.build.lib.vfs.FileSystemUtils; import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.skydoc.rendering.RuleInfo; import java.io.IOException; -import java.io.InputStream; import java.nio.file.Paths; import java.util.Map; import java.util.Map.Entry; @@ -51,16 +50,7 @@ public final class SkydocTest extends SkylarkTestCase { @Override public ParserInputSource inputSource(String pathString) throws IOException { Path path = fileSystem.getPath(pathString); - byte[] bytes = null; - try (InputStream in = path.getInputStream()) { - bytes = new ByteSource() { - @Override - public InputStream openStream() throws IOException { - return in; - } - }.read(); - } - + byte[] bytes = FileSystemUtils.asByteSource(path).read(); return ParserInputSource.create(bytes, path.asFragment()); } }); |