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

Prevent NullPointerException when matching filenames in SourceUtils #5279

Merged
merged 1 commit into from
Jan 14, 2023

Conversation

matthiasblaesing
Copy link
Contributor

Closes: #5266

@matthiasblaesing matthiasblaesing added Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) ci:all-tests [ci] enable all tests labels Jan 11, 2023
@matthiasblaesing matthiasblaesing added this to the NB17 milestone Jan 11, 2023
Copy link
Member

@mbien mbien left a comment

Choose a reason for hiding this comment

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

The Match class initialized with a null name would never match anything. This may or may not be intended. Hopefully this doesn't cause silent issues now which don't throw exceptions. cc @jlahoda

but this is probably still a good hotfix so +1 from me.

if (name.equals(fo.getNameExt())) {
if (fo.getNameExt().equals(name)) {
Copy link
Member

Choose a reason for hiding this comment

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

good that getNameExt() returns empty Strings. This makes it better than the JDK 20 proposal of the Path API which was luckily dropped last minute because of it returning null:
https://bugs.openjdk.org/browse/JDK-8297814

I already had a code inspection for that ready expecting it to be a common bug.

new version is the PR 11545 which might make it into JDK 21 following the same null safe logic

good choice back then @jtulach!

@matthiasblaesing
Copy link
Contributor Author

Seems to work and is minimally invasive, so lets get this in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:all-tests [ci] enable all tests Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Extract source name from .class and use it to locate proper source" (#5152) breaks java source editing
2 participants