aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar ulfjack <ulfjack@google.com>2017-05-30 09:41:46 +0200
committerGravatar László Csomor <laszlocsomor@google.com>2017-05-30 09:57:25 +0200
commitefbb25b2b3953b5e1b4af0e2b90733622583948c (patch)
tree181347794abe43214960ae57c0a30b7c181356c2 /src
parent29ec1b89989db411d2038e2df8657b6435f80403 (diff)
RemoteSpawnStrategy: don't round-trip through String
Instead, print the downloaded bytes directly to stdout / stderr. PiperOrigin-RevId: 157435933
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnStrategy.java17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnStrategy.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnStrategy.java
index 537643990b..1848b8845d 100644
--- a/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnStrategy.java
+++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnStrategy.java
@@ -14,8 +14,6 @@
package com.google.devtools.build.lib.remote;
-import static java.nio.charset.StandardCharsets.UTF_8;
-
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
@@ -187,12 +185,21 @@ final class RemoteSpawnStrategy implements SpawnActionContext {
}
private static void passRemoteOutErr(
- RemoteActionCache cache, ActionResult result, FileOutErr outErr) {
+ RemoteActionCache cache, ActionResult result, FileOutErr outErr) throws IOException {
try {
ImmutableList<byte[]> streams =
cache.downloadBlobs(ImmutableList.of(result.getStdoutDigest(), result.getStderrDigest()));
- outErr.printOut(new String(streams.get(0), UTF_8));
- outErr.printErr(new String(streams.get(1), UTF_8));
+ byte[] stdout = streams.get(0);
+ byte[] stderr = streams.get(1);
+ // Don't round-trip through String - write to the output streams directly.
+ if (stdout.length != 0) {
+ outErr.getOutputStream().write(stdout);
+ outErr.getOutputStream().flush();
+ }
+ if (stderr.length != 0) {
+ outErr.getErrorStream().write(stderr);
+ outErr.getErrorStream().flush();
+ }
} catch (CacheNotFoundException e) {
// Ignoring.
}