Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop doing actions.write UTF-8. This was causing a double encode. #11496

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

package com.google.devtools.build.lib.analysis.actions;

import static java.nio.charset.StandardCharsets.UTF_8;

import com.google.common.annotations.VisibleForTesting;
import com.google.devtools.build.lib.actions.ActionExecutionContext;
import com.google.devtools.build.lib.actions.ActionKeyContext;
Expand All @@ -39,7 +37,8 @@
/**
* Action to write a file whose contents are known at analysis time.
*
* <p>The output is always UTF-8 encoded.
* <p>The output is not reencoded in any way. That is, the raw bytes from BUILD
* and .bzl files for string attributes will be emitted exactly as read.
*
* <p>TODO(bazel-team): Choose a better name to distinguish this class from {@link
* BinaryFileWriteAction}.
Expand Down Expand Up @@ -171,7 +170,7 @@ private static final class CompressedString extends LazyString {
final int uncompressedSize;

CompressedString(String chars) {
byte[] dataToCompress = chars.getBytes(UTF_8);
byte[] dataToCompress = chars.getBytes();
ByteArrayOutputStream byteStream = new ByteArrayOutputStream(dataToCompress.length);
try (GZIPOutputStream zipStream = new GZIPOutputStream(byteStream)) {
zipStream.write(dataToCompress);
Expand Down Expand Up @@ -202,7 +201,7 @@ public String toString() {
// This should be impossible since we're reading from a byte array.
throw new RuntimeException(e);
}
return new String(uncompressedBytes, UTF_8);
return new String(uncompressedBytes);
}
}

Expand Down Expand Up @@ -235,7 +234,7 @@ public DeterministicWriter newDeterministicWriter(ActionExecutionContext ctx) {
return new DeterministicWriter() {
@Override
public void writeOutputFile(OutputStream out) throws IOException {
out.write(getFileContents().getBytes(UTF_8));
out.write(getFileContents().getBytes());
}
};
}
Expand Down