Skip to content

In order to handle non standard HTTP Status codes returned by services in RestTemplate, I would like to add support for handling non standard status codes and passing on responses for these responses to callers [SPR-9311] #13949

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
spring-projects-issues opened this issue Apr 5, 2012 · 3 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Apr 5, 2012

harish opened SPR-9311 and commented

Currently Resttemplate uses an enum of 'standard' HTTP status codes, that is subset of all legally possible HTTP status codes that services can return. When a non standard HTTP status code is returned by services, an IllegalArgumentException is thrown and all response body is ignored. We call services that use custom code 450 for user validation errors along with an xml containing list of messages codes and message text. Unfortunately we get only an illegal argument exception and response body is lost. I think it would be helpful if say all 4xx, 1xx, 2xx, 5xx are treated as legal responses and their response bodies are preserved and passed to the caller. At the least a hook could be provided to extend the enum used by Resttemplate to add additional HTTP codes that caller might expect.


Issue Links:

2 votes, 3 watchers

@spring-projects-issues
Copy link
Collaborator Author

harish commented

This is blocking us from using RestTemplate. Is there a way to bump up the priority?

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Apr 13, 2012

Arjen Poutsma commented

I believe the functionality you seek is already there, see #11418

@spring-projects-issues
Copy link
Collaborator Author

harish commented

Thanks Arjen. Using a custom error handler gets us past this, but we find that we get errors at other places (where ever HttpsStatus is accessed internally by resttenplate). Seems it's tightly coupled to HttpStatus Enum. Since all 1xx,2xx,3xx, 4xx and 5xx are legal, it seems natural that HttpStatus enum include them or not to throw illegalStateException when passed. I think treating all these codes as legal by HttpStatus enum will help us a lot.

@spring-projects-issues spring-projects-issues added status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement in: web Issues in web modules (web, webmvc, webflux, websocket) labels Jan 11, 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) status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants