tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject DO NOT REPLY [Bug 49972] Double-check idiom. Possible data-race.
Date Wed, 22 Sep 2010 10:53:28 GMT

--- Comment #1 from Sebb <> 2010-09-22 06:53:24 EDT ---
The currentDateGenerated field is read outside the synch. block, and is not

So if one thread calls getCurrentDate() and updates the field, another thread
calling getCurrentDate() may see a stale value. 

Now a stale value will be smaller than the proper value, so the worst that can
happen is that the synch. block is invoked unnecessarily. The synch. block will
pick up the true value, and skip the format call if necessary.

However, this assumes that the field is only updated by the getCurrentDate()
method. As the field is not private, that is not guranteed.

Seems to me that the field should be made private, and a comment added to
explain why the double-check is OK in this case.

If read-only access is needed, a getter could be added for the binary field.

Configure bugmail:
------- You are receiving this mail because: -------
You are the assignee for the bug.

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

View raw message