The fix will have a problem when called by multiple threads. Strictly
speaking, DateFormatSymbols isn't thread-safe, but the usage of
cachedHashCode will have a problem even with no set* calls.
I'd suggest the following.
int hashCode =cachedHashCode;
if (hashCode == 0) {
...
cachedHashCode = hashCode;
}
return hashCode;
And cachedHashCode needs to be volatile. And when a DateFormatSymbols is
mutated, the cachedHashCode value needs to be reset.
Masayoshi
On 10/5/2012 6:44 AM, Naoto Sato wrote:
Hello,
Please review the fix for the following bug:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7200341
Proposed changes are located at:
http://cr.openjdk.java.net/~naoto/7200341/webrev.00/
The fix is to re-implement hashCode() correctly. It now also takes all
the fields into consideration for hash code calculation.
Naoto