java - Spring Boot in standalone Tomcat ignores exceptions set in DeferredResults -


i'm running spring boot 1.2.1 application in standalone tomcat.

i have 2 controller mappings, both simplicity throw exception. first 1 request , returns string view name:

    @requestmapping(value = {     "/index" }, method = requestmethod.get) public string init() throws myrequestprocessingexception {     if (true) {     throw new myrequestprocessingexception(             "something went wrong processing request");     }     return "init"; } 

this exception definition:

@responsestatus(value=httpstatus.internal_server_error) public class myrequestprocessingexception extends exception {  public myrequestprocessingexception(string message) {     super(message); }    } 

in embedded tomcat in standalone tomcat, trying access /index results in 500 json error data being returned client.

my controller has method accepts post , returns deferredresult:

   @requestmapping(value = "html/start", method = requestmethod.post, consumes = application_form_urlencoded) public deferredresult<string> start(final httpservletresponse response,                                     @valid @modelattribute final initialisationstartattributes model,                                     final sessiondata sessionexisting) throws myrequestprocessingexception {     final deferredresult<string> finalresult = new deferredresult<>(5000);                  // return error, can test                 if (true) {                     finalresult.seterrorresult(new myrequestprocessingexception(                             "something went wrong processing request"));                 }      return finalresult; } 

in embedded tomcat, post /html/start returns 500 json data in response body, other request method. however, when try reproduce behaviour using standalone tomcat instance, 200 response no response body.

i'm using tomcat 8 in embedded , tomcat 7.0.52 standalone, i've tried standalone tomcat 8 , doesn't make difference.

my application deployed in root application context modifying /etc/tomcat/catalina/localhost/root.xml.

edit: i've done bit more testing, , seem deferredresult culprit. have yet override handleerrorresult() see happens. i'm bit surprised though, because don't recall seeing in documentation difference between returning deferredresult in embedded vs standalone tomcat.

if throw exception in @requestmapping , don't handle anywhere, response status not set before hit errorpagefilter. if want map status error path in customizer, need handle error , status set in filter chain somewhere (e.g. @exceptionhandler or using exception @responsestatus). way custom error page render map exceptions instead of (or as) httpstatus, using new errorpage(exception.class, "/html/error").


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -