tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Hauser <>
Subject Re: HttpSessionListener: Negative session count
Date Tue, 12 Aug 2003 14:14:04 GMT
Hi Yoav

That could be the problem as well. So if the server is restarted my 
session counter variable is set to 0, but there might still be 30 active 

I didn't think of that problem, because I thought that the sessions 
would be invalidated when the server is restarted.

Has anyone a good solution to this problem? Or should I just prevent the 
session counter variable from becoming negative and after a while 
(session timeout for all remaining sessions) the counter will be working 
correctly again?


Shapira, Yoav wrote:

> Howdy,
> I would mention one other possibility, unrelated to synchronization,
> which may cause this behavior.
> If your session listener simply increments a counter on every
> sessionCreated() and decrements the counter on every sessionDestroyed(),
> it is vulnerable to this behavior.
> When the server is restarted, if there are active sessions they are
> persisted by default.  Then the server comes back up, and all these
> sessions are active, without a session created event, so your listener
> has a counter value of 0, but there are actually >0 active sessions.
> When these are destroyed as usual, sessionDestroyed() will be called for
> them, decrementing your counter and resulting in a negative value.
> Yoav Shapira
> Millennium ChemInformatics

View raw message