You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a controller returning a DeferredResult throws an exception, as in the example below, Tomcat will ignore the exception and return an HTTP 200 with no response body.
@RequestMapping(value = "html/start", method = RequestMethod.POST, consumes =APPLICATION_FORM_URLENCODED)
publicDeferredResult<String> start(finalHttpServletResponseresponse,
@Valid@ModelAttributefinalInitialisationStartAttributesmodel,
finalSessionDatasessionExisting) throwsMyRequestProcessingException {
finalDeferredResult<String> finalResult = newDeferredResult<>(5000);
// Just return an error, so we can testif (true) {
finalResult.setErrorResult(newMyRequestProcessingException(
"Something went wrong processing request"));
}
returnfinalResult;
}
I've managed to work around this to some extent by defining my own @ExceptionHandler for all exceptions, which I can use to return the correct status, but it's pervasive - affects the response status throughout the whole filter chain. Thus filters and interceptors which are supposed to log the response status will not work.
It does look similar to #1920, but he says it's happening with embedded Tomcat and I'm only seeing this when I deploy into standalone Tomcat. Also not sure (without running the example) whether the expected status code is being returned.
When a controller returning a DeferredResult throws an exception, as in the example below, Tomcat will ignore the exception and return an HTTP 200 with no response body.
The exception is annotated with @ResponseStatus.
If this is executed in a Spring Boot embedded context it will return 500 as one would expect.
I'm running 1.2.1 RELEASE.
The text was updated successfully, but these errors were encountered: