Author: mmillson
Date: 2010-12-09 14:52:14 -0500 (Thu, 09 Dec 2010)
New Revision: 1619
Modified:
branches/JBOSSWEB_2_0_0_GA_CP14_JBPAPP-5560/src/share/classes/org/apache/catalina/connector/Response.java
branches/JBOSSWEB_2_0_0_GA_CP14_JBPAPP-5560/src/share/classes/org/apache/catalina/core/StandardHostValve.java
branches/JBOSSWEB_2_0_0_GA_CP14_JBPAPP-5560/src/share/classes/org/apache/catalina/session/StandardSession.java
Log:
Session attribute NullPointerException checks and allow extra response headers to be sent
with a custom error page for [JBPAPP-5560].
Modified:
branches/JBOSSWEB_2_0_0_GA_CP14_JBPAPP-5560/src/share/classes/org/apache/catalina/connector/Response.java
===================================================================
---
branches/JBOSSWEB_2_0_0_GA_CP14_JBPAPP-5560/src/share/classes/org/apache/catalina/connector/Response.java 2010-12-09
19:00:06 UTC (rev 1618)
+++
branches/JBOSSWEB_2_0_0_GA_CP14_JBPAPP-5560/src/share/classes/org/apache/catalina/connector/Response.java 2010-12-09
19:52:14 UTC (rev 1619)
@@ -675,6 +675,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:
branches/JBOSSWEB_2_0_0_GA_CP14_JBPAPP-5560/src/share/classes/org/apache/catalina/core/StandardHostValve.java
===================================================================
---
branches/JBOSSWEB_2_0_0_GA_CP14_JBPAPP-5560/src/share/classes/org/apache/catalina/core/StandardHostValve.java 2010-12-09
19:00:06 UTC (rev 1618)
+++
branches/JBOSSWEB_2_0_0_GA_CP14_JBPAPP-5560/src/share/classes/org/apache/catalina/core/StandardHostValve.java 2010-12-09
19:52:14 UTC (rev 1619)
@@ -368,7 +368,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);
@@ -406,15 +406,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:
branches/JBOSSWEB_2_0_0_GA_CP14_JBPAPP-5560/src/share/classes/org/apache/catalina/session/StandardSession.java
===================================================================
---
branches/JBOSSWEB_2_0_0_GA_CP14_JBPAPP-5560/src/share/classes/org/apache/catalina/session/StandardSession.java 2010-12-09
19:00:06 UTC (rev 1618)
+++
branches/JBOSSWEB_2_0_0_GA_CP14_JBPAPP-5560/src/share/classes/org/apache/catalina/session/StandardSession.java 2010-12-09
19:52:14 UTC (rev 1619)
@@ -1032,6 +1032,10 @@
throw new IllegalStateException
(sm.getString("standardSession.getAttribute.ise"));
+ if (name == null) {
+ return null;
+ }
+
return (attributes.get(name));
}
@@ -1634,6 +1638,9 @@
*/
protected void removeAttributeInternal(String name, boolean notify) {
+ // Avoid NPE
+ if (name == null) return;
+
// Remove this attribute from our collection
Object value = attributes.remove(name);
Show replies by date