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: setProviderAndWait must throw #794

Merged
merged 2 commits into from
Feb 8, 2024
Merged

fix: setProviderAndWait must throw #794

merged 2 commits into from
Feb 8, 2024

Conversation

toddbaert
Copy link
Member

@toddbaert toddbaert commented Feb 7, 2024

As per 1.1.2.4, the blocking provider setter must throw if init fails, so that application integrators can easily understand if their provider is working without attaching event handlers.

We implemented the wait functionality of this method, but we swallow the exception.

This PR fixes that.

@toddbaert toddbaert requested a review from a team as a code owner February 7, 2024 20:02
try (AutoCloseableLock __ = lock.writeLockAutoCloseable()) {
providerRepository.setProvider(
provider,
this::attachEventProvider,
this::emitReady,
this::detachEventProvider,
this::emitError,
this::emitErrorAndThrow,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the main change - I pass a new delegate which not only emits the events, but throws.

Copy link

codecov bot commented Feb 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (d5a0620) 94.87% compared to head (78aec5b) 95.13%.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #794      +/-   ##
============================================
+ Coverage     94.87%   95.13%   +0.26%     
- Complexity      366      368       +2     
============================================
  Files            34       34              
  Lines           858      863       +5     
  Branches         53       53              
============================================
+ Hits            814      821       +7     
+ Misses           23       22       -1     
+ Partials         21       20       -1     
Flag Coverage Δ
unittests 95.13% <100.00%> (+0.26%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
ProviderEventDetails.builder().message(exception.getMessage()).build());
}

private void emitErrorAndThrow(FeatureProvider provider, OpenFeatureError exception) throws OpenFeatureError {
Copy link
Member Author

@toddbaert toddbaert Feb 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New delegate which emits errors but also throws.

Copy link

sonarcloud bot commented Feb 8, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@toddbaert toddbaert merged commit da47b7f into main Feb 8, 2024
10 checks passed
@toddbaert toddbaert deleted the set-and-wait-throw branch February 8, 2024 20:19
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