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

Java Runtime now incorrectly reports Cannot read field "stderr" because "consoleOutput" is null #4801

Open
1 task done
TimothyJones opened this issue Mar 20, 2025 · 1 comment · May be fixed by #4802
Open
1 task done
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. potential-regression Marking this issue as a potential regression to be checked by team member

Comments

@TimothyJones
Copy link
Contributor

Describe the bug

In the java version of jsii 1.109.0, the runner now reports:

Unexpected error in background thread "software.amazon.jsii.JsiiRuntime.ErrorStreamSink": java.lang.NullPointerException: Cannot read field "stderr" because "consoleOutput" is null

on every run.

The way the jsii Java runner works is that there's a thread that reads standard error for json objects. It reads each line, tries to parse them to json, and if it fails with an exception, it will print the line instead.

There's a small mistake in the runtime, where the buffer is flushed on EOF, even if it is empty. This would have failed the json parsing, and printed a newline to standard error (probably no one noticed this - I certainly didn't).

Unfortunately, Jackson-Databind 2.18.3 contains a change, where json nodes that aren't present will now return null instead of throwing an exception as they did previously. This changes the behaviour for empty string.

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

No errors to be printed on a successful run

Current Behavior

The following error is printed to standard out

Unexpected error in background thread "software.amazon.jsii.JsiiRuntime.ErrorStreamSink": java.lang.NullPointerException: Cannot read field "stderr" because "consoleOutput" is null

Reproduction Steps

Run any java code that calls jsii with v1.109.0

Possible Solution

The fix is twofold:

  1. Don't flush an empty buffer on EOF (ie, this line)
  2. Handle a null return from objectMapper.treeToValue here

Additional Information/Context

Happy to produce a PR if you like

SDK version used

1.109.0

Environment details (OS name and version, etc.)

openjdk 23.0.1, node v22.9.0, MacOS 14.4.1

@TimothyJones TimothyJones added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Mar 20, 2025
@github-actions github-actions bot added the potential-regression Marking this issue as a potential regression to be checked by team member label Mar 20, 2025
@TimothyJones
Copy link
Contributor Author

Pull request #4802 raised to address this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. potential-regression Marking this issue as a potential regression to be checked by team member
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant