aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com
diff options
context:
space:
mode:
authorGravatar Eric Fellheimer <felly@google.com>2015-11-04 01:20:00 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2015-11-04 16:09:52 +0000
commit7f68994aaebc60f55c18e73dc5515d9798a1c9de (patch)
tree5109a6d3f6eb0a0b3d06e5a2cfca596f94cae24b /src/main/java/com
parent3b06cd3ec198bba2b5f4111a49460d98d3796084 (diff)
Avoid copying file contents when reading the expected number of bytes in#readContentWithLimit().
-- MOS_MIGRATED_REVID=106995917
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/google/devtools/build/lib/vfs/FileSystemUtils.java2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/vfs/FileSystemUtils.java b/src/main/java/com/google/devtools/build/lib/vfs/FileSystemUtils.java
index 0fd54f591d..4ec7699670 100644
--- a/src/main/java/com/google/devtools/build/lib/vfs/FileSystemUtils.java
+++ b/src/main/java/com/google/devtools/build/lib/vfs/FileSystemUtils.java
@@ -956,7 +956,7 @@ public class FileSystemUtils {
byte[] buffer = new byte[limit];
try (InputStream inputStream = byteSource.openBufferedStream()) {
int read = ByteStreams.read(inputStream, buffer, 0, limit);
- return Arrays.copyOf(buffer, read);
+ return read == limit ? buffer : Arrays.copyOf(buffer, read);
}
}