tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Caldarale, Charles R" <Chuck.Caldar...@unisys.com>
Subject RE: session.isNew() not thread safe?
Date Mon, 02 Mar 2009 22:11:48 GMT
> From: Christopher Schultz [mailto:chris@christopherschultz.net]
> Subject: Re: session.isNew() not thread safe?
>
> Thus, you cannot guarantee that using the session object itself for
> synchronization (like doing "synchronized(session) { ... }"
> in your code will give you exclusive access to your session object.

Correct, which is another reason why Karl San Gabriel's suggestion was not only nonsense,
but dangerous.

> I'm not entirely convinced this exclusive access is necessary,
> since mostly people are doing set/get attribute calls and those
> will be fine.

It's only necessary when you need to take an additional (usually one-time) action based on
the presence of some attribute in the session; in that case, synchronization on something
else common to the servlets of the webapp is necessary.

> You can't even throw an object into the session to be
> used as a monitor

Actually you can - you just need to do it with an HttpSessionListener when the HttpSession
is first created, before any additional threads can get their paws on it.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus
for use only by the intended recipient. If you received this in error, please contact the
sender and delete the e-mail and its attachments from all computers.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message