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

[BEAM-14539] Ensure that the print stream can handle larger byte arrays being written and also allow for a growable amount of carry over. #17787

Merged
merged 2 commits into from
Jun 2, 2022

Conversation

lukecwik
Copy link
Member


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Choose reviewer(s) and mention them in a comment (R: @username).
  • Format the pull request title like [BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replace BEAM-XXX with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests

See CI.md for more information about GitHub Actions CI.

…ys being written and also allow for a growable amount of carry over.
@lukecwik
Copy link
Member Author

R: @scwhittle

Note that we never looped during decoding which lead to us copying the remainder of bytes over.

@@ -65,8 +65,7 @@ private static class JulHandlerPrintStream extends PrintStream {
private final Level messageLevel;
private final CharsetDecoder decoder;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it be good to add annotations that these are guarded?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -130,46 +128,50 @@ public synchronized void write(int i) {
@Override
public void write(byte[] a, int offset, int length) {
ByteBuffer incoming = ByteBuffer.wrap(a, offset, length);
assert incoming.hasArray();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could return early for length == 0, not obvious if this would hold in that case

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it still does hold, added code to return early for length == 0

for (LogRecord logRecord : handler.getLogs()) {
actualMessages.append(logRecord.getMessage());
}
assertThat(actualMessages.toString(), containsString(msg + newlineMsg));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could this be equals instead of containsString?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, had to expose output warning since that is the prefix.

@scwhittle
Copy link
Contributor

Otherwise LGTM

@lukecwik
Copy link
Member Author

lukecwik commented Jun 1, 2022

Run Java PreCommit

1 similar comment
@lukecwik
Copy link
Member Author

lukecwik commented Jun 1, 2022

Run Java PreCommit

@lukecwik lukecwik merged commit 999bcea into apache:master Jun 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants