Skip to content
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

Can't wrap a ClientResponse with a custom status code in a builder #23366

Closed
marcingrzejszczak opened this issue Jul 26, 2019 · 1 comment
Closed
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@marcingrzejszczak
Copy link
Contributor

marcingrzejszczak commented Jul 26, 2019

When using Spring WebFlux 5.1.8.RELEASE consider having the following code

ClientResponse response = ...;
ClientResponse wrapped = ClientResponse.from(response)
					.body(response.bodyToFlux(DataBuffer.class)
					.transform(this.scopePassingTransformer))
					.build()

when response contains a custom status code e.g. 499 the DefaultClientResponseBuilder in the constructor uses statusCode(other.statusCode()); and statusCode() throws an exception since it's a custom status code.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jul 26, 2019
@rstoyanchev rstoyanchev added in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jul 26, 2019
@rstoyanchev rstoyanchev added this to the 5.1.9 milestone Jul 26, 2019
@rstoyanchev
Copy link
Contributor

ClientHttpResponse and ClientResponse support custom status codes, but ClientResponse.Builder doesn't. In the very least ClientResponse.from(response) should not fail i this case.

marcingrzejszczak added a commit to spring-cloud/spring-cloud-sleuth that referenced this issue Jul 26, 2019
curently whenever we try to retrieve the http status we get an exception for custom codes
we've migrated to using the raw status code. Also, due to spring-projects/spring-framework#23366 we had to manually wrap the ClientResponse so as we don't throw an exception on httpStatus() method

fixes gh-1393
@poutsma poutsma self-assigned this Jul 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

4 participants