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 ResponseFacade.java
Date Mon, 01 Nov 2004 23:34:04 GMT
luehe       2004/11/01 15:34:04

  Modified:    catalina/src/share/org/apache/catalina/connector
                        ResponseFacade.java
  Log:
  Throw more meaningful exception (instead of NPE) if underlying response
  has been recycled and attempt is made to access it via its facade
  
  Revision  Changes    Path
  1.8       +86 -6     jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/connector/ResponseFacade.java
  
  Index: ResponseFacade.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/connector/ResponseFacade.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ResponseFacade.java	1 Nov 2004 23:21:58 -0000	1.7
  +++ ResponseFacade.java	1 Nov 2004 23:34:04 -0000	1.8
  @@ -29,6 +29,7 @@
   import javax.servlet.http.Cookie;
   import javax.servlet.http.HttpServletResponse;
   
  +import org.apache.catalina.util.StringManager;
   
   /**
    * Facade class that wraps a Coyote response object. 
  @@ -38,8 +39,6 @@
    * @author Jean-Francois Arcand
    * @version $Revision$ $Date$
    */
  -
  -
   public class ResponseFacade 
       implements HttpServletResponse {
   
  @@ -98,7 +97,14 @@
       }
   
   
  -    // ----------------------------------------------------- Instance Variables
  +    // ----------------------------------------------- Class/Instance Variables
  +
  +
  +    /**
  +     * The string manager for this package.
  +     */
  +    protected static StringManager sm =
  +        StringManager.getManager(Constants.Package);
   
   
       /**
  @@ -120,15 +126,23 @@
   
       public void finish() {
   
  -        response.setSuspended(true);
  +        if (response == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("responseFacade.nullResponse"));
  +        }
   
  +        response.setSuspended(true);
       }
   
   
       public boolean isFinished() {
   
  -        return response.isSuspended();
  +        if (response == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("responseFacade.nullResponse"));
  +        }
   
  +        return response.isSuspended();
       }
   
   
  @@ -136,6 +150,12 @@
   
   
       public String getCharacterEncoding() {
  +
  +        if (response == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("responseFacade.nullResponse"));
  +        }
  +
           return response.getCharacterEncoding();
       }
   
  @@ -205,6 +225,12 @@
   
   
       public int getBufferSize() {
  +
  +        if (response == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("responseFacade.nullResponse"));
  +        }
  +
           return response.getBufferSize();
       }
   
  @@ -255,6 +281,12 @@
   
   
       public boolean isCommitted() {
  +
  +        if (response == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("responseFacade.nullResponse"));
  +        }
  +
           return (response.isAppCommitted());
       }
   
  @@ -280,6 +312,12 @@
   
   
       public Locale getLocale() {
  +
  +        if (response == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("responseFacade.nullResponse"));
  +        }
  +
           return response.getLocale();
       }
   
  @@ -295,26 +333,56 @@
   
   
       public boolean containsHeader(String name) {
  +
  +        if (response == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("responseFacade.nullResponse"));
  +        }
  +
           return response.containsHeader(name);
       }
   
   
       public String encodeURL(String url) {
  +
  +        if (response == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("responseFacade.nullResponse"));
  +        }
  +
           return response.encodeURL(url);
       }
   
   
       public String encodeRedirectURL(String url) {
  +
  +        if (response == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("responseFacade.nullResponse"));
  +        }
  +
           return response.encodeRedirectURL(url);
       }
   
   
       public String encodeUrl(String url) {
  +
  +        if (response == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("responseFacade.nullResponse"));
  +        }
  +
           return response.encodeURL(url);
       }
   
   
       public String encodeRedirectUrl(String url) {
  +
  +        if (response == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("responseFacade.nullResponse"));
  +        }
  +
           return response.encodeRedirectURL(url);
       }
   
  @@ -451,11 +519,23 @@
   
   
       public String getContentType() {
  +
  +        if (response == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("responseFacade.nullResponse"));
  +        }
  +
           return response.getContentType();
       }
   
   
       public void setCharacterEncoding(String arg0) {
  +
  +        if (response == null) {
  +            throw new IllegalStateException(
  +                            sm.getString("responseFacade.nullResponse"));
  +        }
  +
           response.setCharacterEncoding(arg0);
       }
   
  
  
  

---------------------------------------------------------------------
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