tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Mutsaers <>
Subject HttpSession instance is differenct for each new request!
Date Wed, 09 Apr 2003 08:10:37 GMT
Until recently we used the session object in order to synchronize some
blocks on:

synchronized ( request.getSession() ) { ... }

Yesterday I found out that each time you call request.getSession(),
tomcat/catalina returns another instance of SessionFacade. Each
instance represents the same session (getAttribute and getId return
the same values each time) but still it is very unfortunate and
questinable that a different object is returned each time (causing
synchronization on the session object to break).

Is this normal, should not the same object be returned every time? Has
it maybe been fixed in newer tomcat versions (we are still using

Now I have to go through great lengths in order to create a unique
Object as session-attribute to synchronzie on instead:

synchronized ( request.getSession().getAttribute("theSyncObject") )

Initially creating this attribute needs to be synchronized on the
session as well, creating a chicken and egg problem :) Now I was
forced to synchronize this step on the application (on some basic
Class object).

Peter Mutsaers, Dübendorf, Switzerland.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message