> From: Leon Rosenberg [mailto:[EMAIL PROTECTED]
> Subject: request for enlightening - StandardSession and expiring flag

> Correct me if I'm wrong, but if two threads come in simultaneously
> into this method, wouldn't they both bypass the first check for
> expiring==true and the synchronized block would be executed twice?

Probably, but we can't tell for sure without knowing whether or the expiration 
process sets manager = null.  If it does, then the expired field is simply a 
mild performance enhancement to avoid blocking during session expiration.

However, a quick browse through the code didn't turn up any calls that would 
clear the manager field directly (e.g., recycle()) during expiration; of 
course, I could have just missed it.  If there is no clearing of the manager 
field done by something called within the synchronized block, then yes, this is 
a bug.

> Shouldn't a check whether the session is already expired by a previous
> call be added after the synchronized(this) statement?

Yes; the check for manager == null may be sufficient (but I couldn't prove it), 
but it would be more straightforward to add a check for isValid inside the 
block.  (Note that the isValid() method is also unsynchronized, which is likely 
to be another bug.)

 - 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to