-
Notifications
You must be signed in to change notification settings - Fork 61
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
ReplaceDuplicateStringLiterals
throws NPE from 1.19.0+ #384
#385
Conversation
src/test/java/org/openrewrite/staticanalysis/ReplaceDuplicateStringLiteralsTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/staticanalysis/ReplaceDuplicateStringLiteralsTest.java
Outdated
Show resolved
Hide resolved
ReplaceDuplicateStringLiterals
throws NPE from 1.19.0+ #384
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the clear report here @adambir ! Turns out my IDE warned about the same potential NPE that you were seeing. Fixed now by adjusting the condition just above.
@timtebeek Would you mind checking this fix again? The previous logic was effectively "! instanceof String", and the negation is lost now. While I can't really judge the overall condition, the code after the if-condition supports my claim: In line 236 is an explicit getValue().toString() (indicating this is not instanceof String yet). Compare that to line 242, where getValue() is taken directly after checking instanceof String. |
Keen eye there! I've restored the original conditiona and added another to indeed handle these cases correctly, thanks! |
What's changed?
Added a test for issue #384 on the ReplaceDuplicateStringLiterals recipe.
What's your motivation?
Allow reproduction of the bug
Checklist