-
Notifications
You must be signed in to change notification settings - Fork 41
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
fix: Do not throw null reference exception accessing a missing item. #300
fix: Do not throw null reference exception accessing a missing item. #300
Conversation
Signed-off-by: Ryan Lamb <[email protected]>
Codecov Report
@@ Coverage Diff @@
## main #300 +/- ##
=========================================
Coverage 91.80% 91.80%
- Complexity 212 213 +1
=========================================
Files 23 23
Lines 488 488
Branches 30 31 +1
=========================================
Hits 448 448
Misses 24 24
Partials 16 16
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@@ -50,7 +50,7 @@ public Set<String> keySet() { | |||
@Override | |||
public Value getValue(String key) { | |||
Value value = this.attributes.get(key); | |||
return value.clone(); | |||
return value != null ? value.clone() : null; |
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 finding/fixing/testing this. I don't think we have a similar issue in MutableStructure
(the older implementation) because we don't clone the retrieved value.
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
This PR
I noticed when implementing a provider that accessing a missing item from an ImmutableContext throws an exception instead of returning null. I do not believe this to be the desired behavior.
How to test
I think the added unit test should cover it.