Repository navigation
fix(sentinel): isolate default degrade rules per resource - #4416
Open
yushiwuzhengjianyuzi wants to merge 1 commit into
Open
yushiwuzhengjianyuzi wants to merge 1 commit into
yushiwuzhengjianyuzi wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe what this PR does / why we need it
Fixes #4411.
Sentinel circuit breakers configured with the same default degrade rule mutated that shared rule while applying it to a resource. Creating a breaker for a second resource therefore overwrote the resource name of the first rule and removed protection for the earlier resource. This also mutated the shared default configuration object.
This change copies each degrade rule before assigning it to a resource, for both synchronous and reactive circuit breakers.
Does this pull request fix one issue?
Yes. Fixes #4411.
Describe how you did it
Added
DegradeRuleUtils.copyForResourceto create an independentDegradeRulewhile preserving all configurable fields. BothSentinelCircuitBreakerandReactiveSentinelCircuitBreakernow add a copy instead of mutating the supplied rule.Describe how to verify it
Added regression tests for both circuit breaker implementations. The tests create breakers for two resources and verify that both rules remain active and the original default rule is unchanged.
Result: 17 tests passed, 0 failures, 0 errors. Checkstyle reports 0 violations.
Special notes for reviews
The test command uses Maven 3.8.8 locally, so Maven emits the known warning that the project requires at least 3.9.1; the build and tests complete successfully. Codex provided AI assistance with the patch and regression tests. This does not claim human review.