Skip to content

fix(java-runtime): ErrorStreamSink crashes with NullPointerException #4803

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

Merged
merged 1 commit into from
Mar 26, 2025

Conversation

iliapolo
Copy link
Contributor

@iliapolo iliapolo commented Mar 24, 2025

All credit for the detection and fix goes to @TimothyJones and his PR. This just adds a unit test on top of it.

Thanks @TimothyJones !

Fixes #4801


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

runtime.getClient().createObject("Object", Collections.emptyList(), Collections.emptyList(),
Collections.emptyList());
runtime.terminate();
Assertions.assertFalse(err.toString().contains(
Copy link
Contributor Author

@iliapolo iliapolo Mar 24, 2025

Choose a reason for hiding this comment

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

Better ideas (that don't require a major refactor) are welcome.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could we instead test for the explicit error output we expect? That should be known and stable for the test, no?

assertEquals(err.toString(), "whatever the expected output is");

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the throwable object is also in that message and i'd prefer not to assert on stack traces.

System.err.printf("Unexpected error in background thread \"%s\": %s%n", thread.getName(), throwable);

I think it asserts on enough of the message to make it unique to this scenario, no?

@TimothyJones
Copy link
Contributor

Thank you! I would assert that the output is empty, rather than it doesn't contain this specific error. But, thank you for adding the test!

@TimothyJones
Copy link
Contributor

Feel free to raise this against my branch instead- that way we both get the commit credits (I noticed mine are missing from this one for some reason)

@iliapolo iliapolo marked this pull request as draft March 25, 2025 15:10
@iliapolo
Copy link
Contributor Author

@TimothyJones how about just copy-paste the code for the test I added and submit a new PR with it? That would also work, than I can approve it and merge :)

@iliapolo iliapolo marked this pull request as ready for review March 26, 2025 10:08
@iliapolo iliapolo marked this pull request as draft March 26, 2025 10:53
@iliapolo iliapolo force-pushed the epolon/error-steam-sink-crash branch from 6d1cfd0 to b9c3a10 Compare March 26, 2025 11:01
@iliapolo iliapolo marked this pull request as ready for review March 26, 2025 11:02
@iliapolo
Copy link
Contributor Author

@TimothyJones I added you as a co-author to the commit. Thanks again for your work on this issue.

Copy link
Contributor

mergify bot commented Mar 26, 2025

Thank you for contributing! ❤️ I will now look into making sure the PR is up-to-date, then proceed to try and merge it!

@mergify mergify bot added the pr/ready-to-merge This PR is ready to be merged. label Mar 26, 2025
Copy link
Contributor

mergify bot commented Mar 26, 2025

Merging (with squash)...

@mergify mergify bot merged commit b20be37 into main Mar 26, 2025
32 checks passed
@mergify mergify bot deleted the epolon/error-steam-sink-crash branch March 26, 2025 11:35
@mergify mergify bot removed the pr/ready-to-merge This PR is ready to be merged. label Mar 26, 2025
@TimothyJones
Copy link
Contributor

Thank you! Co-author is great.

Thanks for merging!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Java Runtime now incorrectly reports Cannot read field "stderr" because "consoleOutput" is null
3 participants