Skip to content

fix(sentinel): isolate default degrade rules per resource - #4416

Open
yushiwuzhengjianyuzi wants to merge 1 commit into
alibaba:2025.1.xfrom
yushiwuzhengjianyuzi:fix/sentinel-shared-default-rules
Open

yushiwuzhengjianyuzi wants to merge 1 commit into
alibaba:2025.1.xfrom
yushiwuzhengjianyuzi:fix/sentinel-shared-default-rules

Conversation

@yushiwuzhengjianyuzi

Copy link
Copy Markdown

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.copyForResource to create an independent DegradeRule while preserving all configurable fields. Both SentinelCircuitBreaker and ReactiveSentinelCircuitBreaker now 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.

& 'D:\maven3.8\apache-maven-3.8.8\bin\mvn.cmd' `
  -pl spring-cloud-alibaba-starters/spring-cloud-circuitbreaker-sentinel -am test

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.

@CLAassistant

CLAassistant commented Oct 23, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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.

[Bug] Sentinel default rules are lost for earlier resources when another circuit breaker is created

2 participants