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

NPE in JavaModuleLayerModification #394

Open
eliasvasylenko opened this issue Feb 13, 2020 · 1 comment
Open

NPE in JavaModuleLayerModification #394

eliasvasylenko opened this issue Feb 13, 2020 · 1 comment

Comments

@eliasvasylenko
Copy link
Contributor

eliasvasylenko commented Feb 13, 2020

This causes null elements to be included in the stream, which causes the following findFirst to fail with an NPE. Instead of .map(l -> l.findModule(n).orElse(null)) it should probably be something like flatMap(l -> l.findModule(n).stream()). Or if you're targeting earlier versions of Java where that's not in the API, a more awkward map(l -> l.findModule(n)).filter(Optional::isPresent).map(Optional::get).

If the result is is null this indicates an error anyway ... but the NPE prevents the proper exception from being thrown a few lines later with all the relevant information, so it obscures the cause of the problem.

The same mistake appears on lines 91 and 158.

@tomsontom
Copy link
Contributor

Would you mind providing a PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants