markt       2004/02/29 11:07:26

  Modified:    jasper2/src/share/org/apache/jasper/runtime Tag:
                        tomcat_4_branch PageContextImpl.java
  Log:
  Fix bug 15754. PageContext.setAttribute() should throw a NPE if name or object are 
null.
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.11.2.7  +32 -24    
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.11.2.6
  retrieving revision 1.11.2.7
  diff -u -r1.11.2.6 -r1.11.2.7
  --- PageContextImpl.java      5 Feb 2004 22:19:08 -0000       1.11.2.6
  +++ PageContextImpl.java      29 Feb 2004 19:07:26 -0000      1.11.2.7
  @@ -229,33 +229,41 @@
   
   
       public void setAttribute(String name, Object attribute) {
  -     attributes.put(name, attribute);
  +        setAttribute(name, attribute, PAGE_SCOPE);
       }
   
  -
       public void setAttribute(String name, Object o, int scope) {
  -     switch (scope) {
  -         case PAGE_SCOPE:
  -             attributes.put(name, o);
  -         break;
  -
  -         case REQUEST_SCOPE:
  -             request.setAttribute(name, o);
  -         break;
  -
  -         case SESSION_SCOPE:
  -             if (session == null)
  -                 throw new IllegalArgumentException("can't access SESSION_SCOPE 
without an HttpSession");
  -             else
  -                 session.setAttribute(name, o);
  -         break;
  -
  -         case APPLICATION_SCOPE:
  -             context.setAttribute(name, o);
  -         break;
  +        if (name == null) {
  +            throw new NullPointerException("name may not be null");
  +        }
  +
  +        if (o == null) {
  +            throw new NullPointerException("object may not be null");
  +        }
  +
  +        switch (scope) {
  +            case PAGE_SCOPE:
  +                attributes.put(name, o);
  +                break;
  +
  +            case REQUEST_SCOPE:
  +                request.setAttribute(name, o);
  +                break;
  +
  +            case SESSION_SCOPE:
  +                if (session == null)
  +                    throw new IllegalArgumentException
  +                        ("can't access SESSION_SCOPE without an HttpSession");
  +                else
  +                    session.setAttribute(name, o);
  +                break;
  +
  +            case APPLICATION_SCOPE:
  +                context.setAttribute(name, o);
  +                break;
   
  -         default:
  -     }
  +            default:
  +        }
       }
   
       public void removeAttribute(String name, int scope) {
  
  
  

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

Reply via email to