You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by cr...@locus.apache.org on 2000/09/01 23:45:57 UTC

cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector HttpRequestBase.java HttpResponseBase.java

craigmcc    00/09/01 14:45:57

  Modified:    catalina/src/share/org/apache/catalina/connector
                        HttpRequestBase.java HttpResponseBase.java
  Log:
  Avoid NullPointerException problems if certain methods are called when no
  context has yet been set.  The only reported case of this was when
  Catalina was started with no webapps at all, but better safe than sorry.
  
  Revision  Changes    Path
  1.7       +18 -5     jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/HttpRequestBase.java
  
  Index: HttpRequestBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/HttpRequestBase.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- HttpRequestBase.java	2000/09/01 18:17:15	1.6
  +++ HttpRequestBase.java	2000/09/01 21:45:55	1.7
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/HttpRequestBase.java,v 1.6 2000/09/01 18:17:15 craigmcc Exp $
  - * $Revision: 1.6 $
  - * $Date: 2000/09/01 18:17:15 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/HttpRequestBase.java,v 1.7 2000/09/01 21:45:55 craigmcc Exp $
  + * $Revision: 1.7 $
  + * $Date: 2000/09/01 21:45:55 $
    *
    * ====================================================================
    *
  @@ -98,7 +98,7 @@
    * be implemented.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.6 $ $Date: 2000/09/01 18:17:15 $
  + * @version $Revision: 1.7 $ $Date: 2000/09/01 21:45:55 $
    */
   
   public class HttpRequestBase
  @@ -659,6 +659,9 @@
        */
       public RequestDispatcher getRequestDispatcher(String path) {
   
  +        if (context == null)
  +            return (null);
  +
   	// If the path is already context-relative, just pass it through
   	if (path == null)
   	    return (null);
  @@ -851,6 +854,9 @@
        */
       public String getPathTranslated() {
   
  +        if (context == null)
  +            return (null);
  +
   	if (pathInfo == null)
   	    return (null);
   	else
  @@ -979,7 +985,9 @@
   	    return (session.getSession());
   
   	// Return the requested session if it exists and is valid
  -	Manager manager = context.getManager();
  +	Manager manager = null;
  +        if (context != null)
  +            manager = context.getManager();
   	if (manager == null)
   	    return (null);	// Sessions are not supported
   	if (requestedSessionId != null) {
  @@ -1058,6 +1066,8 @@
   
   	if (requestedSessionId == null)
   	    return (false);
  +        if (context == null)
  +            return (false);
   	Manager manager = context.getManager();
   	if (manager == null)
   	    return (false);
  @@ -1082,6 +1092,9 @@
        * @param role Role name to be validated
        */
       public boolean isUserInRole(String role) {
  +
  +        if (context == null)
  +            return (false);
   
   	// Respect role name translations in the deployment descriptor
   	String realRole = context.findRoleMapping(role);
  
  
  
  1.6       +7 -5      jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/HttpResponseBase.java
  
  Index: HttpResponseBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/HttpResponseBase.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- HttpResponseBase.java	2000/08/24 23:56:56	1.5
  +++ HttpResponseBase.java	2000/09/01 21:45:56	1.6
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/HttpResponseBase.java,v 1.5 2000/08/24 23:56:56 craigmcc Exp $
  - * $Revision: 1.5 $
  - * $Date: 2000/08/24 23:56:56 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/HttpResponseBase.java,v 1.6 2000/09/01 21:45:56 craigmcc Exp $
  + * $Revision: 1.6 $
  + * $Date: 2000/09/01 21:45:56 $
    *
    * ====================================================================
    *
  @@ -96,7 +96,7 @@
    * methods need to be implemented.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.5 $ $Date: 2000/08/24 23:56:56 $
  + * @version $Revision: 1.6 $ $Date: 2000/09/01 21:45:56 $
    */
   
   public class HttpResponseBase
  @@ -480,7 +480,9 @@
   	    Cookie cookie = new Cookie(Globals.SESSION_COOKIE_NAME,
   				       session.getId());
   	    cookie.setMaxAge(-1);
  -	    String contextPath = context.getPath();
  +	    String contextPath = null;
  +            if (context != null)
  +                contextPath = context.getPath();
   	    if ((contextPath != null) && (contextPath.length() > 0))
   		cookie.setPath(contextPath);
   	    if (hreq.isSecure())