-
Notifications
You must be signed in to change notification settings - Fork 40.7k
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
Spring Webflux 406 errors when ContentType of Method differs from ExceptionHandler #13635
Comments
@bclozel As requested on Gitter, here's the issue. |
406
errors when ContentType of Method differs from ExceptionHandler
@bclozel Wondering if you might have any thoughts on this issue. Thanks in advance. |
Thanks for the report @pluttrell ! I'm about to solve it and the fix will ship with Spring Framework 5.0.8 and 5.1.0.RC1, so Spring Boot 2.0.4 and 2.1.0.M1. I'm marking it as invalid because technically the issue is not in Spring Boot, but it doesn't mean your contribution is not valued. Thanks! |
@bclozel When upgrading to 2.1.0.M4, this issue was resolved. However when moving to 2.1.0.RC1, the issue came back. I've reported the potential regression here: https://jira.spring.io/browse/SPR-17415 |
@bclozel I have exactly same issue with spring-boot 2.1.1.RELEASE. an I missing something ? |
@bidadh I don't know - could you create a new issue with a sample application that demonstrates the problem? |
@bclozel yes I can. I thought because this is exactly the same issue maybe it's better to add a comment. I can also add Controller and ExceptionHandler code here which one easier for you ? |
A new issue with a complete repro app (for example in a github repo of yours). Sometimes those are tied to dependency management or other issues so a complete repro makes things easier and faster to fix. |
Hi @bclozel I've created this issue and here is the repository Could you please have a look ? Thanks, |
I'm using Spring Webflux and seeing
406
errors when both of the following occur:This is reproducible using SpringBoot v2.0.3 and v2.1.0-BUILD-SNAPSHOT (as of today).
The
AccessKeyValidationService
does a blocking lookup, so naturally needs to return aMono
and thus needs to be part of theMono
returned from the controller:A valid apiKey, results in proper binary output:
When I throw an exception before the Reactive Stream, I get the intended JSON output:
But when I trigger the steam to error with an
IllegalAccessException
, I get a406
:If I put a breakpoint in the
handleIllegalAccessException
method, it stops as expected.If I switch the return type for the controller method to JSON it works as expected.
Is there something else I need to do to switch the response type when erroring out the returned
Mono
? Or some other way to resolve it?Here's a repo with a failing unit test reproducing the problem: https://github.com/pluttrell/spring-webflux-binary-response-exception-handling-example
The text was updated successfully, but these errors were encountered: