Author: remy.maucherat(a)jboss.com
Date: 2009-11-18 22:02:03 -0500 (Wed, 18 Nov 2009)
New Revision: 1276
Modified:
trunk/java/org/apache/catalina/connector/Request.java
trunk/webapps/docs/changelog.xml
Log:
- Add null checks for context, like there is in other places in Request.
Modified: trunk/java/org/apache/catalina/connector/Request.java
===================================================================
--- trunk/java/org/apache/catalina/connector/Request.java 2009-11-18 16:56:02 UTC (rev
1275)
+++ trunk/java/org/apache/catalina/connector/Request.java 2009-11-19 03:02:03 UTC (rev
1276)
@@ -1512,6 +1512,9 @@
return;
}
+ if (context == null)
+ return;
+
// Notify interested application event listeners
Object listeners[] = context.getApplicationEventListeners();
if ((listeners == null) || (listeners.length == 0))
@@ -1582,6 +1585,9 @@
coyoteRequest.setAttribute(name, value);
}
+ if (context == null)
+ return;
+
// Notify interested application event listeners
Object listeners[] = context.getApplicationEventListeners();
if ((listeners == null) || (listeners.length == 0))
@@ -2466,9 +2472,7 @@
return (session);
// Return the requested session if it exists and is valid
- Manager manager = null;
- if (context != null)
- manager = context.getManager();
+ Manager manager = context.getManager();
if (manager == null)
return (null); // Sessions are not supported
if (requestedSessionId != null) {
@@ -2488,7 +2492,7 @@
// Create a new session if requested and the response is not committed
if (!create)
return (null);
- if ((context != null) && (response != null) &&
+ if ((response != null) &&
context.getCookies() &&
response.getResponse().isCommitted()) {
throw new IllegalStateException
@@ -2524,8 +2528,7 @@
// Creating a new session cookie based on that session
// If there was no cookie with the current session id, add a cookie to the
response
- if ( (session != null) && (getContext() != null)
- && getContext().getCookies()
+ if ( (session != null) && context.getCookies()
&& !(isRequestedSessionIdFromCookie() &&
(session.getIdInternal().equals(getRequestedSessionId()))) ) {
String cookieName = context.getSessionCookie().getName();
if (cookieName == null) {
@@ -2647,6 +2650,9 @@
parametersParsed = true;
+ if (context == null)
+ return;
+
Parameters parameters = coyoteRequest.getParameters();
// getCharacterEncoding() may have been overridden to search for
@@ -2789,6 +2795,9 @@
protected void parseMultipart()
throws IOException, ServletException {
+ if (context == null)
+ return;
+
Multipart config = wrapper.getMultipartConfig();
if (config == null) {
return;
@@ -3039,7 +3048,7 @@
throw new
IllegalStateException(sm.getString("coyoteRequest.noAsync"));
}
// ISE if response is closed
- if (response.isClosed()) {
+ if (response.isClosed() || context == null) {
throw new
IllegalStateException(sm.getString("coyoteRequest.closed"));
}
// ISE if this method is called again without any asynchronous dispatch
@@ -3073,7 +3082,7 @@
public boolean authenticate(HttpServletResponse response) throws IOException,
ServletException {
- if (context.getAuthenticator() != null) {
+ if (context != null && context.getAuthenticator() != null) {
return context.getAuthenticator().authenticate(this, response);
} else {
throw new
ServletException(sm.getString("coyoteRequest.noAuthenticator"));
@@ -3084,7 +3093,7 @@
if (userPrincipal != null) {
throw new
ServletException(sm.getString("coyoteRequest.authFailed"));
}
- if (context.getAuthenticator() != null) {
+ if (context != null && context.getAuthenticator() != null) {
context.getAuthenticator().login(this, username, password);
} else {
throw new
ServletException(sm.getString("coyoteRequest.noAuthenticator"));
@@ -3096,7 +3105,7 @@
public void logout() throws ServletException {
Principal principal = userPrincipal;
- if (context.getAuthenticator() != null) {
+ if (context != null && context.getAuthenticator() != null) {
context.getAuthenticator().logout(this);
} else {
userPrincipal = null;
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2009-11-18 16:56:02 UTC (rev 1275)
+++ trunk/webapps/docs/changelog.xml 2009-11-19 03:02:03 UTC (rev 1276)
@@ -139,6 +139,9 @@
<fix>
<jboss-jira>JBAS-7159</jboss-jira>: Better usability for Context
level usage of RewriteValve. (remm)
</fix>
+ <fix>
+ <jira>148</jira>: Add additional null checks for unmapped contexts.
(remm)
+ </fix>
</changelog>
</subsection>
<subsection name="Coyote">
Show replies by date