| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
This pull request optimizes the initialization of hookSupportData.hints in OpenFeatureClient.java by using Collections.emptyMap() when the hook hints are empty. A review comment points out that getHookHints() could return null, which would cause a NullPointerException when calling isEmpty(), and suggests adding a null check to handle this case safely.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Sorry, something went wrong.
| var hookHints = flagOptions.getHookHints(); | ||
| hookSupportData.hints = hookHints.isEmpty() ? Collections.emptyMap() : Collections.unmodifiableMap(hookHints); |
There was a problem hiding this comment.
If flagOptions.getHookHints() returns null (which can happen if hookHints is explicitly set to null via the builder in FlagEvaluationOptions), calling hookHints.isEmpty() will throw a NullPointerException.
To ensure robust defensive programming, we should handle the null case gracefully by defaulting to Collections.emptyMap().
| var hookHints = flagOptions.getHookHints(); | |
| hookSupportData.hints = hookHints.isEmpty() ? Collections.emptyMap() : Collections.unmodifiableMap(hookHints); | |
| var hookHints = flagOptions.getHookHints(); | |
| hookSupportData.hints = hookHints == null || hookHints.isEmpty() ? Collections.emptyMap() : Collections.unmodifiableMap(hookHints); |
Sorry, something went wrong.
There was a problem hiding this comment.
I think this is something that should be handled in the builder, but idk if we can modify this, since I assume it will be a lombok builder. Can we add a test to make sure we won't have a NPE?
Sorry, something went wrong.
There was a problem hiding this comment.
ensured in builder that it can't be null
Sorry, something went wrong.
Signed-off-by: Tobias Ibounig <tobias.ibounig@dynatrace.com>
|
Same codecov-action issue as #1955 (comment) - rebasing this PR onto main should fix it. cc @chrfwow |
Sorry, something went wrong.
Signed-off-by: Tobias Ibounig <tobias.ibounig@dynatrace.com>
|
Realized another thing in FlagEvaluationOptions. Builder Default is currently new HashMap<>();, would it make sense to change this to Collections.emptyMap()? |
Sorry, something went wrong.
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #1953 +/- ##
============================================
+ Coverage 92.26% 93.28% +1.02%
- Complexity 654 658 +4
============================================
Files 59 59
Lines 1590 1594 +4
Branches 179 181 +2
============================================
+ Hits 1467 1487 +20
+ Misses 76 62 -14
+ Partials 47 45 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness.
|
Sorry, something went wrong.
Signed-off-by: Tobias Ibounig <tobias.ibounig@dynatrace.com>
|
The current build issue can be fixed by running spotless:apply |
Sorry, something went wrong.
Oh sorry, I thought I made sure to run it every time. |
Sorry, something went wrong.
That one seems like a breaking change probably not worth the improvement. |
Sorry, something went wrong.
|
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This PR
Related Issues
None
Notes
hookHints is resolved once per flag evaluation. Previously it was always wrapped in an unmodifiable view, even when empty. This PR avoids that allocation by returning Collections.emptyMap() directly when there are
no hints.
Allocation impact is negligible, but reduces on totalAllocatedInstances can be seen.
Follow-up Tasks