Author: markt Date: Fri Nov 6 15:04:46 2015 New Revision: 1712974 URL: http://svn.apache.org/viewvc?rev=1712974&view=rev Log: Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=58581 If custom error page fails, fall back to standard error page rather than throwing an NPE. Based on a patch by Huxing Zhang.
Modified: tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties tomcat/trunk/java/org/apache/catalina/core/StandardHostValve.java Modified: tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties?rev=1712974&r1=1712973&r2=1712974&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties (original) +++ tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties Fri Nov 6 15:04:46 2015 @@ -185,6 +185,7 @@ standardHost.noContext=No Context config standardHost.notContext=Child of a Host must be a Context standardHost.nullName=Host name is required standardHost.problematicAppBase=Using an empty string for appBase on host [{0}] will set it to CATALINA_BASE, which is a bad idea +standardHostValue.customStatusFailed=Custom error page [{0}] could not be dispatched correctly standardServer.accept.timeout=The socket listening for the shutdown command experienced an unexpected timeout [{0}] milliseconds after the call to accept(). Is this an instance of bug 56684? standardServer.shutdownViaPort=A valid shutdown command was received via the shutdown port. Stopping the Server instance. standardServer.storeConfig.notAvailable=No StoreConfig implementation was registered as an MBean named [{0}] so no configuration could be saved. A suitable MBean is normally registered via the StoreConfigLifecyleListener. Modified: tomcat/trunk/java/org/apache/catalina/core/StandardHostValve.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardHostValve.java?rev=1712974&r1=1712973&r2=1712974&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/core/StandardHostValve.java (original) +++ tomcat/trunk/java/org/apache/catalina/core/StandardHostValve.java Fri Nov 6 15:04:46 2015 @@ -231,7 +231,7 @@ final class StandardHostValve extends Va // Look for a default error page errorPage = context.findErrorPage(0); } - if (errorPage != null && response.setErrorReported()) { + if (errorPage != null && response.isErrorReportRequired()) { response.setAppCommitted(false); request.setAttribute(RequestDispatcher.ERROR_STATUS_CODE, Integer.valueOf(statusCode)); @@ -255,6 +255,7 @@ final class StandardHostValve extends Va request.setAttribute(RequestDispatcher.ERROR_REQUEST_URI, request.getRequestURI()); if (custom(request, response, errorPage)) { + response.setErrorReported(); try { response.finishResponse(); } catch (ClientAbortException e) { @@ -379,6 +380,12 @@ final class StandardHostValve extends Va RequestDispatcher rd = servletContext.getRequestDispatcher(errorPage.getLocation()); + if (rd == null) { + container.getLogger().error( + sm.getString("standardHostValue.customStatusFailed", errorPage.getLocation())); + return false; + } + if (response.isCommitted()) { // Response is committed - including the error page is the // best we can do --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org