Repository navigation
Fix NoSuchMethodError in webflux adapter block handler on Spring WebFlux 6.x - #3678
Open
amalsaidov wants to merge 1 commit into
Open
amalsaidov wants to merge 1 commit into
amalsaidov wants to merge 1 commit into
Conversation
… 6.x ServerResponse.status(HttpStatus) was removed in Spring Framework 6.0 in favor of status(HttpStatusCode). The webflux adapter is compiled against Spring 5.3, so its bytecode references status(HttpStatus), which no longer exists at runtime on Spring WebFlux 6.x (Spring Boot 3). Triggering a flow control rule therefore throws NoSuchMethodError while building the block response instead of returning HTTP 429. Use the status(int) overload, which is present in both Spring 5.3 and 6.x, keeping full backward compatibility while fixing the runtime failure. Signed-off-by: Amal Saidov <amalsaidov@users.noreply.github.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.
Describe what this PR does / why we need it
DefaultBlockRequestHandlerbuilds its block response withServerResponse.status(HttpStatus.TOO_MANY_REQUESTS). TheServerResponse.status(HttpStatus)overload was removed in Spring Framework 6.0 in favor ofstatus(HttpStatusCode). Because the adapter is compiled against Spring 5.3, its bytecode references the oldstatus(HttpStatus)signature, which no longer exists at runtime on Spring WebFlux 6.x (Spring Boot 3).As a result, when a flow rule is triggered the handler throws
java.lang.NoSuchMethodErrorwhile building the block response instead of returning HTTP 429:This lets the adapter run on Spring WebFlux 6.x without forcing a Spring dependency upgrade.
Does this pull request fix one issue?
Fixes #3677
Describe how you did it
Switched to the
ServerResponse.status(int)overload (HttpStatus.TOO_MANY_REQUESTS.value()) in both the JSON and HTML branches.status(int)is present in both Spring 5.3 and Spring 6.x, so the fix keeps full backward compatibility with the current Spring 5.3 baseline while resolving the runtime failure. The status value is unchanged (429).status(HttpStatus)is the only API in this handler that was binary-removed in Spring 6;fromObject,syncBodyandAPPLICATION_JSON_UTF8are still present (deprecated) in Spring 6.2.x, so no other change is required to fix the reported crash.Describe how to verify it
Build and run the module's existing tests:
SentinelWebFluxIntegrationTest(6 tests) passes.testWebFluxRouterFunctionandtestCustomizedRequestOriginParserboth drive the default block handler and assertHttpStatus.TOO_MANY_REQUESTSwith the block message, confirming the behavior is unchanged on Spring 5.3. The fix makes the same code path work under Spring WebFlux 6.x, where it previously threwNoSuchMethodError.Special notes for reviews
Minimal, backward-compatible change (2 lines). No new dependency or Spring version bump.