Use binary class name to resolve per-class HTTP interface fallbacks - #1715
Open
HDPark95 wants to merge 1 commit into
Open
Use binary class name to resolve per-class HTTP interface fallbacks#1715HDPark95 wants to merge 1 commit into
HDPark95 wants to merge 1 commit into
Conversation
CircuitBreakerRequestValueProcessor stored the declaring class under its canonical name, while fallbacks are registered per service using Class#getName() (the binary name). For a nested @HttpExchange interface these two forms differ (Outer.Inner vs Outer$Inner), so the per-class fallback was never matched and the invocation fell through to the default fallback or NoFallbackAvailableException. Store the binary name so the declaring-class lookup key matches the registration key. Top-level interfaces are unaffected because their canonical and binary names are identical. Signed-off-by: HDPark95 <qkrgusen456@gmail.com>
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.
What
CircuitBreakerRequestValueProcessorrecords the declaring class of the invoked@HttpExchangemethod undergetCanonicalName(), but per-class fallbacks are registered withClass#getName()(the binary name) inCircuitBreakerConfigurerUtils.addFallbackEntries.getFallbackthen resolves the fallback by looking up that recorded value.For a top-level interface both forms are identical, but for a nested
@HttpExchangeinterface they differ:com.example.Outer.Inner(canonical) vscom.example.Outer$Inner(binary). The lookup key never matches the registration key, so the per-class fallback is silently skipped and the invocation falls through to thedefaultfallback or, when none is registered, throwsNoFallbackAvailableException.Fix
Record the declaring class under
getName()so the declaring-class lookup key matches the registration key. Top-level interfaces are unaffected because their canonical and binary names are identical.This circuit-breaking-over-
@HttpExchangesupport is new in 5.0.0 and unreleased, so aligning the stored attribute carries no compatibility concern.Verification
shouldResolvePerClassFallbackForNestedServiceInterfacetoCircuitBreakerAdapterDecoratorTests, which drives the realCircuitBreakerRequestValueProcessorwith a nested service interface and asserts the per-class fallback resolves.NoFallbackAvailableException; with the fix the whole test class passes (Tests run: 6, Failures: 0, Errors: 0)../mvnw -pl spring-cloud-commons testis green, including spring-javaformat and checkstyle validation.