-
Notifications
You must be signed in to change notification settings - Fork 38.4k
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
Update documentation to explain streaming vs collecting and error handling with Flux<T>
return values
#32630
Comments
What you have described is the expected behavior. If the response has been committed already, headers and partial body might have been sent to the client over the network already. Are you requesting a change of behavior here? Can you explain what it is? |
Previously, As I see, having a method in the controller with a return type |
We did switch from collecting into a List to streaming. This reduces memory usage but also provides control to collect via |
Flux<T>
return values
But wouldn't it make sense to approach encoding based on the media type that is supposed to be produced? As a user, if my intention is to return an |
The trade-off is additional memory to aggregate, and if we aggregate by default, there is no way to get it to behave whichever way you prefer. This way, you can choose to aggregate or not. I suppose we could make this configurable in some way, if you would be okay to switch it wholesale. |
Affects: 6.1.5
Description
@RestController
which is producingFlux<T>
asMediaType.APPLICATION_JSON_VALUE
will fail to encode an error, handled by@RestControllerAdvice
, if the Flux contains multiple signals starting with the first oneonNext
followed byonError
(s) after it.Such signal arrangement in the
Flux
will result in a stacktrace that looks like this as theAbstractJackson2Encoder
will fail to encode the error because the ServerHttpResponse was already committed and partially transferred to the client (the first item from theFlux
withonNext
):Testing with Mozilla Firefox client
Testing with Postman (v9.25.2)
Steps to reproduce
Demo project with reproducible issue
The text was updated successfully, but these errors were encountered: