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

fix: Do not throw null reference exception accessing a missing item. #300

Conversation

kinyoklion
Copy link
Member

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.

@kinyoklion kinyoklion marked this pull request as ready for review February 16, 2023 02:41
@codecov
Copy link

codecov bot commented Feb 16, 2023

Codecov Report

Merging #300 (2a8a549) into main (7459eaa) will not change coverage.
The diff coverage is 100.00%.

@@            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           
Flag Coverage Δ
unittests 91.80% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...n/java/dev/openfeature/sdk/ImmutableStructure.java 76.19% <100.00%> (ø)

📣 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;
Copy link
Member

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.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@justinabrahms justinabrahms merged commit 464820d into open-feature:main Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants