Spring-cloud-netflix: Ribbon error (e.g. downstream 404 or timeout) in Zuul proxy bypasses normal Spring Boot error handling

Created on 2 Mar 2016  路  6Comments  路  Source: spring-cloud/spring-cloud-netflix

The response is probably being manipulated directly somewhere, so the tomcat error page shows up (HTML) instead of the normal Spring Boot one (JSON).

bug

Most helpful comment

Thanks for the sample app. I raised a ticket in Spring Security for that specific problem (which only seems to show up when you have a custom error handler as you do): https://github.com/spring-projects/spring-security/issues/3780.

I also noticed while investigating this that if there is an error rendering the custom error page you get the same effect.

All 6 comments

I can't reproduce this now. Leaving it open in case it pops back again.

I've reproduced bug using Spring Cloud Brixton.RC1 + Spring Boot 1.3.3.RELEASE + Spring Security. Here is an example:
STR:

Turn Spring Security off:

  • Comment Spring Security dependency in pom.xml file
  • Comment security configuration in application.yml.

Restart app and open URL http://localhost:8765/dummy/ - you will see custom error page.

I debugged program and found that if Spring Security is turned on - app wraps javax.servlet.AsyncContext into org.springframework.security.web.servletapi.HttpServlet3RequestFactory$SecurityContextAsyncContext and Tomcat does not commit Response in method org.apache.catalina.core.ApplicationDispatcher#doForward because of check in line 394.

Also I found that if error happened and response is not committed Tomcat default behavior is to create his own error page: org.apache.catalina.valves.ErrorReportValve#invoke

Thanks for the sample app. I raised a ticket in Spring Security for that specific problem (which only seems to show up when you have a custom error handler as you do): https://github.com/spring-projects/spring-security/issues/3780.

I also noticed while investigating this that if there is an error rendering the custom error page you get the same effect.

@leofromgroza Thanks for the detailed walk through! This appears to be a bug in Tomcat. However, the workaround was simple so I pushed a fix to master. Please see https://github.com/spring-projects/spring-security/issues/3780#issuecomment-204427591 for additional details (including a link to the bug report I filed with Tomcat).

@dsyer @rwinch Thank you guys for so fast reaction. You are really cool! I felt the real power of open source;) Thank you!

@dsyer are we still tracking this here or can we close it?

Was this page helpful?
0 / 5 - 0 ratings