tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Mutsaers <pe...@mutsaers.com>
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
4.0.3)?

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: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message