As the title states, the behavior of WebClient.Builder.defaultStatusHandler() seems inconsistent. If I'm setting a default status handler my expectation is that it handles the status regardless of how the call is done by the client. This becomes particularly important when customizing the builder from a common library, as I need to enforce that the default handling always takes place; Prior to Spring Framework 6 and Spring Boot 3, this could be done via an ExchangeFilterFunction. Now, things get more complicated as exceptions thrown from the exchange filter functions affect the actuator observations, forcing me to override quite some methods just to be able to not lose the response HTTP status on them.
As for documentation, I couldn't find anywhere where this is documented either and, on StackOverflow answers, everything seems to indicate that retrieve() is just a simplification of the exchangeTo* methods when we don't care about more granular control.
Taking all the above into consideration, I'm wondering if there's a good reason why defaultStatusHandler() does only apply to retrieve() calls. Even if that were the case, I think this should be somehow stated in the documentation.
As the title states, the behavior of
WebClient.Builder.defaultStatusHandler()seems inconsistent. If I'm setting a default status handler my expectation is that it handles the status regardless of how the call is done by the client. This becomes particularly important when customizing the builder from a common library, as I need to enforce that the default handling always takes place; Prior to Spring Framework 6 and Spring Boot 3, this could be done via anExchangeFilterFunction. Now, things get more complicated as exceptions thrown from the exchange filter functions affect the actuator observations, forcing me to override quite some methods just to be able to not lose the response HTTP status on them.As for documentation, I couldn't find anywhere where this is documented either and, on StackOverflow answers, everything seems to indicate that
retrieve()is just a simplification of theexchangeTo*methods when we don't care about more granular control.Taking all the above into consideration, I'm wondering if there's a good reason why
defaultStatusHandler()does only apply toretrieve()calls. Even if that were the case, I think this should be somehow stated in the documentation.