You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by cr...@locus.apache.org on 2000/03/31 20:22:35 UTC
cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core RequestImpl.java
craigmcc 00/03/31 10:22:35
Modified: src/share/org/apache/tomcat/core RequestImpl.java
Log:
Allow a new session to be created after invalidating the previous one, in
the context of processing the same request (bug report 55). This makes the
following code sequence work:
HttpSession session = request.getSession(false);
if (session != null)
session.invalidate();
session = request.getSession(true);
long creationTime = session.getCreationTime();
without throwing an IllegalStateException on the last statement. NOTE: this
sequence will be ineffective if the response has already been committed (because
you can no longer add the session ID cookie to the response headers), but that
is also true of creating a new session in the first place -- so I don't see
this as a big problem.
PR:55
Submitted by: jcpage@corp.home.net (bug report), gaborliptak@usa.net (patch)
Revision Changes Path
1.25 +16 -6 jakarta-tomcat/src/share/org/apache/tomcat/core/RequestImpl.java
Index: RequestImpl.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/RequestImpl.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- RequestImpl.java 2000/03/28 00:04:02 1.24
+++ RequestImpl.java 2000/03/31 18:22:34 1.25
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/RequestImpl.java,v 1.24 2000/03/28 00:04:02 costin Exp $
- * $Revision: 1.24 $
- * $Date: 2000/03/28 00:04:02 $
+ * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/RequestImpl.java,v 1.25 2000/03/31 18:22:34 craigmcc Exp $
+ * $Revision: 1.25 $
+ * $Date: 2000/03/31 18:22:34 $
*
* ====================================================================
*
@@ -403,10 +403,20 @@
}
public HttpSession getSession(boolean create) {
- // use the cached value
- if( serverSession!=null )
- return serverSession;
+ // use the cached value, unless it is invalid
+ if( serverSession!=null ) {
+ // Detect "invalidity" by trying to access a property
+ try {
+ serverSession.getCreationTime();
+ return (serverSession);
+ } catch (IllegalStateException e) {
+ // It's invalid, so pretend we never saw it
+ serverSession = null;
+ reqSessionId = null;
+ }
+ }
+
SessionManager sM=context.getSessionManager();
// if the interceptors found a request id, use it