I have an application running on Tomcat 4.1.27, who uses an HttpSessionListener to intercept session invalidations. It runs OK, according with the 2.3 servlet spec, which says that the sessionDestroyed method must be called AFTER the session is already invalidated. (I had a lot of pain to build a logic that could overcome this behavior). Well, today, I moved the same application to Tomcat 5.0.16 and - for my surprise - the sessionDestroyed is now called BEFORE the session is invalidated... I KNOW that this is the correct behavior according to 2.4 servlet spec, and I fixed my listener to work with it. The problem now, is that the sessionDestroyed method is being called TWICE: one BEFORE the session is invalidated and another AFTER the session is already invalidated, in THE SAME INVALIDATION PROCESS ! And more: it only happens when the session expires - after timeout is reached. It does NOT happen when I explicity invalidate the session, with "session.invalidate()". My listener is full of logs and that's the only reason I could figure this out.... I just want to know if this is the correct behavior for the 2.4 servlet spec, or if it's a bug... I can overcome this too, but I think that if there's something wrong, it must fixed... Thanks, Roberto (Ironman)
Please don't whine, we didn't introduce this bug on purpose just to annoy you, and the issue has been fixed already. The patch can be applied easily if you need it. Index: StandardManager.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/session/StandardManager.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- StandardManager.java 29 Nov 2003 18:06:35 -0000 1.15 +++ StandardManager.java 5 Dec 2003 09:28:55 -0000 1.16 @@ -813,13 +813,7 @@ for (int i = 0; i < sessions.length; i++) { StandardSession session = (StandardSession) sessions[i]; if (!session.isValid()) { - try { - expiredSessions++; - session.expire(); - } catch (Throwable t) { - log.error(sm.getString - ("standardManager.expireException"), t); - } + expiredSessions++; } } long timeEnd = System.currentTimeMillis(); *** This bug has been marked as a duplicate of 25234 ***
I didn't mean to sound rude or anything else, guys... It happens that English is not my "mother language" - I use it only for business and technically... So, I don't use to worry about diplomacy while I'm writing - I just go straight to the point. I'm old enough to know that we must treat people the way we want to be treated, but this is something that I do in my natural language only... Well, as I said before, I can overcome that "triggering twice" problem of Tomcat, but I wanted to know WHAT was happening... Now I do...:D And since I don't have the needed patience to apply patches, I'll wait until the next release (or sub-release) of Tomcat... Could you PLEASE tell me when the "5.0.17" sub-release will be available - with this tiny problem fixed ? Thanks for the attention, Roberto