luehe       2003/02/13 15:26:43

  Modified:    jasper2/src/share/org/apache/jasper/resources
                        messages.properties
               jasper2/src/share/org/apache/jasper/runtime
                        JspContextWrapper.java PageContextImpl.java
  Log:
  Implemented semantics for JspContextWrapper that if the name argument
  passed to getAttribute or setAttribute is null, a NPE must be thrown.
  
  Revision  Changes    Path
  1.93      +2 -1      
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/resources/messages.properties
  
  Index: messages.properties
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/resources/messages.properties,v
  retrieving revision 1.92
  retrieving revision 1.93
  diff -u -r1.92 -r1.93
  --- messages.properties       13 Feb 2003 02:41:26 -0000      1.92
  +++ messages.properties       13 Feb 2003 23:26:42 -0000      1.93
  @@ -364,3 +364,4 @@
   jsp.error.variable.alias=Both or none of the name-from-attribute and alias 
attributes can be specified in a variable directive
   jsp.error.prelude.xml=The JSP document {0} has a prelude ({1}) associated with it
   jsp.error.coda.xml=The JSP document {0} has a coda ({1}) associated with it
  +jsp.error.attribute.null_name=Null attribute name
  
  
  
  1.16      +30 -3     
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/JspContextWrapper.java
  
  Index: JspContextWrapper.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/JspContextWrapper.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- JspContextWrapper.java    13 Feb 2003 23:04:26 -0000      1.15
  +++ JspContextWrapper.java    13 Feb 2003 23:26:42 -0000      1.16
  @@ -87,8 +87,11 @@
   import javax.servlet.jsp.el.ELException;
   import javax.servlet.jsp.el.ExpressionEvaluator;
   import javax.servlet.jsp.el.VariableResolver;
  +
   import org.apache.commons.el.VariableResolverImpl;
   
  +import org.apache.jasper.compiler.Localizer;
  +
   /**
    * Implementation of a JSP Context Wrapper.
    *
  @@ -152,10 +155,22 @@
       }
       
       public Object getAttribute(String name) {
  +
  +     if (name == null) {
  +         throw new NullPointerException(
  +                 Localizer.getMessage("jsp.error.attribute.null_name"));
  +     }
  +
        return pageAttributes.get(name);
       }
   
       public Object getAttribute(String name, int scope) {
  +
  +     if (name == null) {
  +         throw new NullPointerException(
  +                 Localizer.getMessage("jsp.error.attribute.null_name"));
  +     }
  +
        if (scope == PAGE_SCOPE) {
            return pageAttributes.get(name);
        }
  @@ -164,6 +179,12 @@
       }
   
       public void setAttribute(String name, Object value) {
  +
  +     if (name == null) {
  +         throw new NullPointerException(
  +                 Localizer.getMessage("jsp.error.attribute.null_name"));
  +     }
  +
        if (value != null) {
            pageAttributes.put(name, value);
        } else {
  @@ -172,6 +193,12 @@
       }
   
       public void setAttribute(String name, Object value, int scope) {
  +
  +     if (name == null) {
  +         throw new NullPointerException(
  +                 Localizer.getMessage("jsp.error.attribute.null_name"));
  +     }
  +
        if (scope == PAGE_SCOPE) {
            if (value != null) {
                pageAttributes.put(name, value);
  
  
  
  1.43      +19 -10    
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/PageContextImpl.java
  
  Index: PageContextImpl.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/PageContextImpl.java,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- PageContextImpl.java      11 Feb 2003 21:43:58 -0000      1.42
  +++ PageContextImpl.java      13 Feb 2003 23:26:42 -0000      1.43
  @@ -265,14 +265,20 @@
       }
   
       public Object getAttribute(String name) {
  -     if (name == null)
  -         throw new NullPointerException("Null name");
  +
  +     if (name == null) {
  +         throw new NullPointerException(
  +                 Localizer.getMessage("jsp.error.attribute.null_name"));
  +     }
        return attributes.get(name);
       }
   
       public Object getAttribute(String name, int scope) {
  -     if (name == null)
  -         throw new NullPointerException("Null name");
  +
  +     if (name == null) {
  +         throw new NullPointerException(
  +                 Localizer.getMessage("jsp.error.attribute.null_name"));
  +     }
   
        switch (scope) {
            case PAGE_SCOPE:
  @@ -297,8 +303,10 @@
       }
   
       public void setAttribute(String name, Object attribute) {
  +
        if (name == null) {
  -         throw new NullPointerException("Null name");
  +         throw new NullPointerException(
  +                 Localizer.getMessage("jsp.error.attribute.null_name"));
        }
   
        if (attribute != null) {
  @@ -308,10 +316,11 @@
        }
       }
   
  -
       public void setAttribute(String name, Object o, int scope) {
  +
        if (name == null) {
  -         throw new NullPointerException("Null name");
  +         throw new NullPointerException(
  +                 Localizer.getMessage("jsp.error.attribute.null_name"));
        }
   
        if (o != null) {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to