markt 2004/01/18 12:38:35
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
- Port from TC5.
Revision Changes Path
1.37 +18 -16
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/session/StandardSession.java
Index: StandardSession.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/session/StandardSession.java,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- StandardSession.java 29 Apr 2003 21:57:58 -0000 1.36
+++ StandardSession.java 18 Jan 2004 20:38:35 -0000 1.37
@@ -65,7 +65,6 @@
package org.apache.catalina.session;
-import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.IOException;
import java.io.NotSerializableException;
@@ -1251,6 +1250,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) {
@@ -1260,21 +1267,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]