Skip to content

fix(java-runtime): ErrorStreamSink no longer fails with a NullPointerException #4802

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

Closed
wants to merge 4 commits 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 @@ -516,7 +516,10 @@ private void acceptData(final boolean uninterruptible) throws IOException {
this.buffer.write(read);
}
if (read == '\n' || this.eof) {
processLine(new String(buffer.toByteArray(), StandardCharsets.UTF_8));
// don't print an empty line if we're at the end of the file and the buffer is empty.
if(!this.eof || buffer.size() > 0) {
processLine(new String(buffer.toByteArray(), StandardCharsets.UTF_8));
}
buffer.reset();
}
}
Expand All @@ -526,6 +529,13 @@ private void processLine(final String line) {
try {
final JsonNode tree = objectMapper.readTree(line);
final ConsoleOutput consoleOutput = objectMapper.treeToValue(tree, ConsoleOutput.class);
if(consoleOutput == null) {
// null means the line was empty, but the above objectMapper calls will return null
// We would throw JsonProcessingException to avoid duplication, but the constructors
// are protected, and the subclasses need too much information
System.err.println(line);
return;
}
if (consoleOutput.stderr != null) {
System.err.write(consoleOutput.stderr, 0, consoleOutput.stderr.length);
}
Expand Down
Loading