larryi 01/02/28 12:43:58
Modified: src/facade22/org/apache/tomcat/facade
Servlet22Interceptor.java
Log:
Fix bug where sessionState() method uses an HttpSessionFacade that
isn't guarateed to be valid.
Submitted by: Frey Thibault
Revision Changes Path
1.12 +19 -3
jakarta-tomcat/src/facade22/org/apache/tomcat/facade/Servlet22Interceptor.java
Index: Servlet22Interceptor.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat/src/facade22/org/apache/tomcat/facade/Servlet22Interceptor.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- Servlet22Interceptor.java 2001/02/17 07:08:18 1.11
+++ Servlet22Interceptor.java 2001/02/28 20:43:58 1.12
@@ -173,7 +173,15 @@
newState==ServerSession.STATE_EXPIRED ) {
// generate "unbould" events when the session is suspended or
- // expired
+ // expired :
+
+ // Session facades are managed by the request facades.
+ // So, the facade returned at this point by the method getFacade()
+ // of ServerSession is not valid : it could refer to a session facade
+ // that is unused, or used by a request facade for another server session.
+ // That's why we have to manage our own facade.
+ HttpSessionFacade sessionFacade = new HttpSessionFacade();
+
Vector removed=new Vector();
Enumeration e = sess.getAttributeNames();
// announce all values with listener that we'll remove them
@@ -181,14 +189,22 @@
String key = (String) e.nextElement();
Object value = sess.getAttribute(key);
- HttpSession httpSess=(HttpSession)sess.getFacade();
+ sessionFacade.setRealSession(sess);
if( value instanceof HttpSessionBindingListener) {
((HttpSessionBindingListener) value).valueUnbound
- (new HttpSessionBindingEvent(httpSess , key));
+ (new HttpSessionBindingEvent(sessionFacade , key));
removed.addElement( key );
}
+
+ // prevents a session crossover
+ sess.setFacade( null );
}
+
+ // helps garbage collector
+ sessionFacade.recycle();
+ sessionFacade = null;
+
// remove
e=removed.elements();
while( e.hasMoreElements() ) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]