tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu...@apache.org
Subject cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/connector RequestFacade.java LocalStrings.properties
Date Mon, 01 Nov 2004 22:38:44 GMT
luehe       2004/11/01 14:38:44

  Modified:    catalina/src/share/org/apache/catalina/connector
                        RequestFacade.java LocalStrings.properties
  Log:
  Throw more meaningful exception (instead of NPE) if underlying request has been
  recycled and attempt is made to access it via its facade
  
  Revision  Changes    Path
  1.7       +335 -9    jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/connector/RequestFacade.java
  
  Index: RequestFacade.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/connector/RequestFacade.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- RequestFacade.java	1 Nov 2004 22:22:37 -0000	1.6
  +++ RequestFacade.java	1 Nov 2004 22:38:44 -0000	1.7
  @@ -31,6 +31,8 @@
   import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpSession;
   
  +import org.apache.catalina.util.StringManager;
  +
   
   /**
    * Facade class that wraps a Coyote request object.  
  @@ -42,9 +44,7 @@
    * @version $Revision$ $Date$
    */
   
  -
  -public class RequestFacade 
  -    implements HttpServletRequest {
  +public class RequestFacade implements HttpServletRequest {
           
           
       // ----------------------------------------------------------- DoPrivileged
  @@ -218,6 +218,13 @@
       protected Request request = null;
   
   
  +    /**
  +     * The string manager for this package.
  +     */
  +    protected static StringManager sm =
  +        StringManager.getManager(Constants.Package);
  +
  +
       // --------------------------------------------------------- Public Methods
   
   
  @@ -233,11 +240,23 @@
   
   
       public Object getAttribute(String name) {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           return request.getAttribute(name);
       }
   
   
       public Enumeration getAttributeNames() {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           if (System.getSecurityManager() != null){
               return (Enumeration)AccessController.doPrivileged(
                   new GetAttributePrivilegedAction());        
  @@ -248,6 +267,12 @@
   
   
       public String getCharacterEncoding() {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           if (System.getSecurityManager() != null){
               return (String)AccessController.doPrivileged(
                   new GetCharacterEncodingPrivilegedAction());
  @@ -258,28 +283,57 @@
   
   
       public void setCharacterEncoding(String env)
  -        throws java.io.UnsupportedEncodingException {
  +            throws java.io.UnsupportedEncodingException {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           request.setCharacterEncoding(env);
       }
   
   
       public int getContentLength() {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           return request.getContentLength();
       }
   
   
       public String getContentType() {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           return request.getContentType();
       }
   
   
  -    public ServletInputStream getInputStream()
  -        throws IOException {
  +    public ServletInputStream getInputStream() throws IOException {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           return request.getInputStream();
       }
   
   
       public String getParameter(String name) {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           if (System.getSecurityManager() != null){
               return (String)AccessController.doPrivileged(
                   new GetParameterPrivilegedAction(name));
  @@ -290,6 +344,12 @@
   
   
       public Enumeration getParameterNames() {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           if (System.getSecurityManager() != null){
               return (Enumeration)AccessController.doPrivileged(
                   new GetParameterNamesPrivilegedAction());
  @@ -301,6 +361,11 @@
   
       public String[] getParameterValues(String name) {
   
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           String[] ret = null;
   
           /*
  @@ -322,6 +387,12 @@
   
   
       public Map getParameterMap() {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           if (System.getSecurityManager() != null){
               return (Map)AccessController.doPrivileged(
                   new GetParameterMapPrivilegedAction());        
  @@ -332,52 +403,111 @@
   
   
       public String getProtocol() {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           return request.getProtocol();
       }
   
   
       public String getScheme() {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           return request.getScheme();
       }
   
   
       public String getServerName() {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           return request.getServerName();
       }
   
   
       public int getServerPort() {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           return request.getServerPort();
       }
   
   
  -    public BufferedReader getReader()
  -        throws IOException {
  +    public BufferedReader getReader() throws IOException {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           return request.getReader();
       }
   
   
       public String getRemoteAddr() {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           return request.getRemoteAddr();
       }
   
   
       public String getRemoteHost() {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           return request.getRemoteHost();
       }
   
   
       public void setAttribute(String name, Object o) {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           request.setAttribute(name, o);
       }
   
   
       public void removeAttribute(String name) {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           request.removeAttribute(name);
       }
   
   
       public Locale getLocale() {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           if (System.getSecurityManager() != null){
               return (Locale)AccessController.doPrivileged(
                   new GetLocalePrivilegedAction());
  @@ -388,6 +518,12 @@
   
   
       public Enumeration getLocales() {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           if (System.getSecurityManager() != null){
               return (Enumeration)AccessController.doPrivileged(
                   new GetLocalesPrivilegedAction());
  @@ -398,11 +534,23 @@
   
   
       public boolean isSecure() {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           return request.isSecure();
       }
   
   
       public RequestDispatcher getRequestDispatcher(String path) {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           if (System.getSecurityManager() != null){
               return (RequestDispatcher)AccessController.doPrivileged(
                   new GetRequestDispatcherPrivilegedAction(path));
  @@ -413,17 +561,34 @@
   
   
       public String getRealPath(String path) {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           return request.getRealPath(path);
       }
   
   
       public String getAuthType() {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           return request.getAuthType();
       }
   
   
       public Cookie[] getCookies() {
   
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           Cookie[] ret = null;
   
           /*
  @@ -445,16 +610,34 @@
   
   
       public long getDateHeader(String name) {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           return request.getDateHeader(name);
       }
   
   
       public String getHeader(String name) {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           return request.getHeader(name);
       }
   
   
       public Enumeration getHeaders(String name) {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           if (System.getSecurityManager() != null){
               return (Enumeration)AccessController.doPrivileged(
                   new GetHeadersPrivilegedAction(name));
  @@ -465,6 +648,12 @@
   
   
       public Enumeration getHeaderNames() {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           if (System.getSecurityManager() != null){
               return (Enumeration)AccessController.doPrivileged(
                   new GetHeaderNamesPrivilegedAction());
  @@ -475,72 +664,155 @@
   
   
       public int getIntHeader(String name) {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           return request.getIntHeader(name);
       }
   
   
       public String getMethod() {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           return request.getMethod();
       }
   
   
       public String getPathInfo() {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           return request.getPathInfo();
       }
   
   
       public String getPathTranslated() {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           return request.getPathTranslated();
       }
   
   
       public String getContextPath() {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           return request.getContextPath();
       }
   
   
       public String getQueryString() {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           return request.getQueryString();
       }
   
   
       public String getRemoteUser() {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           return request.getRemoteUser();
       }
   
   
       public boolean isUserInRole(String role) {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           return request.isUserInRole(role);
       }
   
   
       public java.security.Principal getUserPrincipal() {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           return request.getUserPrincipal();
       }
   
   
       public String getRequestedSessionId() {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           return request.getRequestedSessionId();
       }
   
   
       public String getRequestURI() {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           return request.getRequestURI();
       }
   
   
       public StringBuffer getRequestURL() {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           return request.getRequestURL();
       }
   
   
       public String getServletPath() {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           return request.getServletPath();
       }
   
   
       public HttpSession getSession(boolean create) {
   
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           if (System.getSecurityManager() != null){
               return (HttpSession)AccessController.
                   doPrivileged(new GetSessionPrivilegedAction(create));
  @@ -550,46 +822,100 @@
       }
   
       public HttpSession getSession() {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           return getSession(true);
       }
   
   
       public boolean isRequestedSessionIdValid() {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           return request.isRequestedSessionIdValid();
       }
   
   
       public boolean isRequestedSessionIdFromCookie() {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           return request.isRequestedSessionIdFromCookie();
       }
   
   
       public boolean isRequestedSessionIdFromURL() {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           return request.isRequestedSessionIdFromURL();
       }
   
   
       public boolean isRequestedSessionIdFromUrl() {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           return request.isRequestedSessionIdFromURL();
       }
   
   
       public String getLocalAddr() {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           return request.getLocalAddr();
       }
   
   
       public String getLocalName() {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           return request.getLocalName();
       }
   
   
       public int getLocalPort() {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           return request.getLocalPort();
       }
   
   
       public int getRemotePort() {
  +
  +        if (request == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("requestFacade.nullRequest"));
  +        }
  +
           return request.getRemotePort();
       }
   
  
  
  
  1.4       +1 -1      jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/connector/LocalStrings.properties
  
  Index: LocalStrings.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/connector/LocalStrings.properties,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- LocalStrings.properties	23 Jun 2004 08:24:57 -0000	1.3
  +++ LocalStrings.properties	1 Nov 2004 22:38:44 -0000	1.4
  @@ -44,7 +44,7 @@
   coyoteRequest.listenerStop=Exception sending context destroyed event to listener instance
of class {0}
   coyoteRequest.attributeEvent=Exception thrown by attributes event listener
   coyoteRequest.postTooLarge=Parameters were not parsed because the size of the posted data
was too big. Use the maxPostSize attribute of the connector to resolve this if the application
should accept large POSTs.
  -
  +requestFacade.nullRequest=Null request object
   
   #
   # MapperListener
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message