Author: remy.maucherat(a)jboss.com
Date: 2008-11-03 17:10:24 -0500 (Mon, 03 Nov 2008)
New Revision: 845
Modified:
trunk/java/org/apache/catalina/connector/Response.java
trunk/java/org/apache/catalina/core/StandardHostValve.java
trunk/webapps/docs/changelog.xml
Log:
- Port patch: less heavy handed reset for error pages.
Modified: trunk/java/org/apache/catalina/connector/Response.java
===================================================================
--- trunk/java/org/apache/catalina/connector/Response.java 2008-11-03 22:01:48 UTC (rev
844)
+++ trunk/java/org/apache/catalina/connector/Response.java 2008-11-03 22:10:24 UTC (rev
845)
@@ -690,6 +690,30 @@
/**
+ * Reset the data buffer and the using Writer/Stream flags but not any
+ * status or header information.
+ *
+ * @param resetWriterStreamFlags <code>true</code> if the internal
+ * <code>usingWriter</code>,
<code>usingOutputStream</code>,
+ * <code>isCharacterEncodingSet</code> flags should also be reset
+ *
+ * @exception IllegalStateException if the response has already
+ * been committed
+ */
+ public void resetBuffer(boolean resetWriterStreamFlags) {
+
+ resetBuffer();
+
+ if(resetWriterStreamFlags) {
+ usingOutputStream = false;
+ usingWriter = false;
+ isCharacterEncodingSet = false;
+ }
+
+ }
+
+
+ /**
* Set the buffer size to be used for this Response.
*
* @param size The new buffer size
Modified: trunk/java/org/apache/catalina/core/StandardHostValve.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardHostValve.java 2008-11-03 22:01:48 UTC
(rev 844)
+++ trunk/java/org/apache/catalina/core/StandardHostValve.java 2008-11-03 22:10:24 UTC
(rev 845)
@@ -367,7 +367,7 @@
if (exception == null)
return (null);
- Class clazz = exception.getClass();
+ Class<?> clazz = exception.getClass();
String name = clazz.getName();
while (!Object.class.equals(clazz)) {
ErrorPage errorPage = context.findErrorPage(name);
@@ -405,15 +405,8 @@
try {
- // Reset the response if possible (else IllegalStateException)
- //hres.reset();
// Reset the response (keeping the real error code and message)
- Integer statusCodeObj =
- (Integer) request.getAttribute(Globals.STATUS_CODE_ATTR);
- int statusCode = statusCodeObj.intValue();
- String message =
- (String) request.getAttribute(Globals.ERROR_MESSAGE_ATTR);
- response.reset(statusCode, message);
+ response.resetBuffer(true);
// Forward control to the specified location
ServletContext servletContext =
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2008-11-03 22:01:48 UTC (rev 844)
+++ trunk/webapps/docs/changelog.xml 2008-11-03 22:10:24 UTC (rev 845)
@@ -84,6 +84,9 @@
<fix>
<bug>46105</bug>: Set query string URI encoding when replaying
request. (markt)
</fix>
+ <fix>
+ Only reset the buffer and usage of IS or writer when forwarding to a custom error
page. (markt, remm)
+ </fix>
</changelog>
</subsection>
<subsection name="Coyote">
Show replies by date