markt       2004/01/18 12:37:52

  Modified:    catalina/src/share/org/apache/catalina/session
                        StandardSession.java
  Log:
  - Fix bug 12363. valueBound() must be called before the object is made available
  via getAttribute() .
  Submitted by: Pablo Morales
  
  Revision  Changes    Path
  1.28      +18 -15    
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/session/StandardSession.java
  
  Index: StandardSession.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/session/StandardSession.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- StandardSession.java      31 Dec 2003 21:24:56 -0000      1.27
  +++ StandardSession.java      18 Jan 2004 20:37:52 -0000      1.28
  @@ -1283,6 +1283,14 @@
               throw new IllegalArgumentException
                   (sm.getString("standardSession.setAttribute.iae"));
   
  +        // Construct an event with the new value
  +        HttpSessionBindingEvent event = new HttpSessionBindingEvent
  +                ((HttpSession) this, name, value);
  +
  +        // Call the valueBound() method if necessary
  +        if (value instanceof HttpSessionBindingListener)
  +                ((HttpSessionBindingListener) value).valueBound(event);
  +
           // Replace or add this attribute
           Object unbound = null;
           synchronized (attributes) {
  @@ -1292,21 +1300,16 @@
   
           // Call the valueUnbound() method if necessary
           if ((unbound != null) &&
  -            (unbound instanceof HttpSessionBindingListener)) {
  +                (unbound instanceof HttpSessionBindingListener)) {
               ((HttpSessionBindingListener) unbound).valueUnbound
  -              (new HttpSessionBindingEvent((HttpSession) this, name));
  +                    (new HttpSessionBindingEvent((HttpSession) this, name));
           }
   
  -        // Call the valueBound() method if necessary
  -        HttpSessionBindingEvent event = null;
  +        // Replace the current event with one containing 
  +        // the old value if necesary
           if (unbound != null)
  -            event = new HttpSessionBindingEvent
  -                ((HttpSession) this, name, unbound);
  -        else
  -            event = new HttpSessionBindingEvent
  -                ((HttpSession) this, name, value);
  -        if (value instanceof HttpSessionBindingListener)
  -            ((HttpSessionBindingListener) value).valueBound(event);
  +            event = new HttpSessionBindingEvent((HttpSession) this,
  +                                                name, unbound);
   
           // Notify interested application event listeners
           Context context = (Context) manager.getContainer();
  
  
  

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

Reply via email to