Skip to content

SPR-16819 - Improve handling of unknown status codes by WebClient #1829

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

Closed
wants to merge 4 commits into from

Conversation

denysivano
Copy link

@denysivano denysivano commented May 13, 2018

These changes are aimed to improve handling of unknown status codes by reactive WebClient.

In ClientResponse the getRawStatusCode() method was introduced that allows to obtain raw status code value from response after the corresponding method in reactive ClientHttpResponse was provided (see SPR-16748).

Also the retrieve() method in default WebClient implementation and statusError() in ExchangeFilterFunctions were changed in order to provide support of unknown status codes. The new onStatusCode() (WebClient.ResponseSpec) and statusCodeError() (ExchangeFilterFunctions) methods allow to specify exception function which should be applied on matching the status code (int value) against the specified predicate. The StatusCodePredicates provides convenient way to create predicates for these methods.

https://jira.spring.io/browse/SPR-16819

Prior to this commit, `WebClient.RequestHeadersSpec.retrieve()` always throw
`IllegalArgumentException` on unknown status codes. This commit improves support
of unkwnown status codes and introduces new method - `onStatusCode`, which
allows to apply response error handling for status codes that can't be resolved
through `HttpStatus`. New class `StatusCodePredicates` provides convenient way
to create predicates for `onStatusCode` method.

Issue: SPR-16819
@bclozel bclozel self-assigned this Jul 11, 2018
@bclozel
Copy link
Member

bclozel commented Jul 12, 2018

Merged with 038af9a, see comment on the SPR issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants