Return-Path: Mailing-List: contact tomcat-dev-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list tomcat-dev@jakarta.apache.org Received: (qmail 88165 invoked by uid 500); 31 Mar 2000 18:22:36 -0000 Delivered-To: apmail-jakarta-tomcat-cvs@apache.org Received: (qmail 88160 invoked by uid 1059); 31 Mar 2000 18:22:35 -0000 Date: 31 Mar 2000 18:22:35 -0000 Message-ID: <20000331182235.88159.qmail@locus.apache.org> From: craigmcc@locus.apache.org To: jakarta-tomcat-cvs@apache.org Subject: 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