craigmcc 01/05/21 12:54:04
Modified: catalina/src/share/org/apache/catalina/core
ApplicationContext.java
catalina/src/share/org/apache/catalina/session
StandardSession.java
Log:
Spec compliance bug fix on ServletContextAttributeEvent and
HttpSessionBindingEvent. When an attribute is replaced, the event object
should include the *old* value, not the *new* value.
Revision Changes Path
1.27 +17 -8
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ApplicationContext.java
Index: ApplicationContext.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ApplicationContext.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- ApplicationContext.java 2001/05/16 17:55:58 1.26
+++ ApplicationContext.java 2001/05/21 19:53:56 1.27
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ApplicationContext.java,v
1.26 2001/05/16 17:55:58 remm Exp $
- * $Revision: 1.26 $
- * $Date: 2001/05/16 17:55:58 $
+ * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ApplicationContext.java,v
1.27 2001/05/21 19:53:56 craigmcc Exp $
+ * $Revision: 1.27 $
+ * $Date: 2001/05/21 19:53:56 $
*
* ====================================================================
*
@@ -112,7 +112,7 @@
*
* @author Craig R. McClanahan
* @author Remy Maucherat
- * @version $Revision: 1.26 $ $Date: 2001/05/16 17:55:58 $
+ * @version $Revision: 1.27 $ $Date: 2001/05/21 19:53:56 $
*/
public class ApplicationContext
@@ -888,6 +888,7 @@
return;
}
+ Object oldValue = null;
boolean replaced = false;
// Add or replace the specified attribute
@@ -895,7 +896,8 @@
// Check for read only attribute
if (readOnlyAttributes.containsKey(name))
return;
- if (attributes.get(name) != null)
+ oldValue = attributes.get(name);
+ if (oldValue != null)
replaced = true;
attributes.put(name, value);
}
@@ -904,9 +906,16 @@
Object listeners[] = context.getApplicationListeners();
if ((listeners == null) || (listeners.length == 0))
return;
- ServletContextAttributeEvent event =
- new ServletContextAttributeEvent(context.getServletContext(),
- name, value);
+ ServletContextAttributeEvent event = null;
+ if (replaced)
+ event =
+ new ServletContextAttributeEvent(context.getServletContext(),
+ name, oldValue);
+ else
+ event =
+ new ServletContextAttributeEvent(context.getServletContext(),
+ name, value);
+
for (int i = 0; i < listeners.length; i++) {
if (!(listeners[i] instanceof ServletContextAttributeListener))
continue;
1.20 +11 -6
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.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- StandardSession.java 2001/05/14 04:51:21 1.19
+++ StandardSession.java 2001/05/21 19:54:01 1.20
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/session/StandardSession.java,v
1.19 2001/05/14 04:51:21 craigmcc Exp $
- * $Revision: 1.19 $
- * $Date: 2001/05/14 04:51:21 $
+ * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/session/StandardSession.java,v
1.20 2001/05/21 19:54:01 craigmcc Exp $
+ * $Revision: 1.20 $
+ * $Date: 2001/05/21 19:54:01 $
*
* ====================================================================
*
@@ -111,7 +111,7 @@
* @author Craig R. McClanahan
* @author Sean Legassick
* @author <a href="mailto:[EMAIL PROTECTED]">Jon S. Stevens</a>
- * @version $Revision: 1.19 $ $Date: 2001/05/14 04:51:21 $
+ * @version $Revision: 1.20 $ $Date: 2001/05/21 19:54:01 $
*/
class StandardSession
@@ -1052,8 +1052,13 @@
}
// Call the valueBound() method if necessary
- HttpSessionBindingEvent event =
- new HttpSessionBindingEvent((HttpSession) this, name, value);
+ HttpSessionBindingEvent event = null;
+ 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);