This commit is contained in:
Phillip Webb 2014-06-20 10:28:44 -07:00
parent 445589a5d2
commit bfe4240ed2
2 changed files with 15 additions and 11 deletions

View File

@ -79,9 +79,9 @@ class DataSourceInitializer implements ApplicationListener<DataSourceInitialized
this.applicationContext.publishEvent(new DataSourceInitializedEvent( this.applicationContext.publishEvent(new DataSourceInitializedEvent(
this.dataSource)); this.dataSource));
} }
catch (IllegalStateException e) { catch (IllegalStateException ex) {
logger.warn("Could not send event to complete DataSource initialization (" logger.warn("Could not send event to complete DataSource initialization ("
+ e.getMessage() + ")"); + ex.getMessage() + ")");
} }
} }
} }

View File

@ -136,18 +136,22 @@ class ErrorPageFilter extends AbstractConfigurableEmbeddedServletContainer imple
request.setAttribute(ERROR_EXCEPTION, ex); request.setAttribute(ERROR_EXCEPTION, ex);
request.setAttribute(ERROR_EXCEPTION_TYPE, type.getName()); request.setAttribute(ERROR_EXCEPTION_TYPE, type.getName());
wrapped.sendError(500, ex.getMessage()); wrapped.sendError(500, ex.getMessage());
if (!wrapped.isCommitted()) { forwardToErrorPage(errorPath, request, wrapped);
wrapped.reset(); }
request.getRequestDispatcher(errorPath).forward(request, wrapped);
} private void forwardToErrorPage(String path, HttpServletRequest request,
else { ServletResponse response) throws ServletException, IOException {
String message = "Cannot forward to error page for" if (!response.isCommitted()) {
+ request.getRequestURI() String message = "Cannot forward to error page for" + request.getRequestURI()
+ " (response is committed), so this response may have the wrong status code"; + " (response is committed), so this response may have "
logger.error(message); + "the wrong status code";
// User might see the error page without all the data here but the exception // User might see the error page without all the data here but the exception
// isn't going to help anyone (and it's already been logged) // isn't going to help anyone (and it's already been logged)
logger.error(message);
return;
} }
response.reset();
request.getRequestDispatcher(path).forward(request, response);
} }
private String getErrorPath(Map<Integer, String> map, Integer status) { private String getErrorPath(Map<Integer, String> map, Integer status) {