fix: fixing null pointer exception error#1709
fix: fixing null pointer exception error#1709Ayushman-Gaur wants to merge 4 commits intoopen-feature:mainfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a potential Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request aims to fix a potential NullPointerException by adding a null check when accessing flag metadata, and includes a new test case to verify the fix. While the intention is good, the implementation of the fix in FlagdCore.java appears to be incorrect. The added condition flag.getTargeting() != null is effectively a no-op, as the getTargeting() method never returns null. I have provided a suggestion to correct the implementation to align with the stated goal of the pull request.
tools/flagd-core/src/main/java/dev/openfeature/contrib/tools/flagd/core/FlagdCore.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Ayushman Gaur <ayushmangaur2017@gmail.com>
Signed-off-by: Ayushman Gaur <ayushmangaur2017@gmail.com>
5107b9f to
bd86aad
Compare
|
The CI failure is in the go-feature-flag provider which is unrelated to my changes in flagd-core. This appears to be a pre-existing issue. |
| @@ -273,7 +273,7 @@ private static ImmutableMetadata getFlagMetadata(Map<String, Object> currentFlag | |||
There was a problem hiding this comment.
You should also guard the for loop against currentFlagSetMetadata being null.
Signed-off-by: Ayushman Gaur <ayushmangaur2017@gmail.com>
65230f7 to
c32e838
Compare
cupofcat
left a comment
There was a problem hiding this comment.
Please solve the CI error with formatting too. Thanks for the contribution!
Signed-off-by: Ayushman Gaur <ayushmangaur2017@gmail.com>
fix: null pointer exceptionn error
flag.getMetadata()ingetFlagMetadata()to preventNullPointerException when a flagd server doesn't support metadata.
Related Issues
Fixes #1708
Notes
currentFlagSetMetadatais always initialized as a new HashMap so it won'tbe null, but
flag.getMetadata()can return null on servers that don't supportmetadata. Added a null guard before iterating over it.
How to test
A new test
resolveBooleanValue_flagWithNullMetadata_doesNotThrowNPEhas beenadded to
FlagdCoreTestthat verifies no NPE is thrown when evaluating a flagwith no metadata defined.