Request for review: Race conditions in java.nio.charset.Charset

David Holmes - Sun Microsystems David.Holmes at Sun.COM
Thu Oct 8 04:35:40 UTC 2009


Ulf,

Ulf Zibis said the following on 10/08/09 08:58:
> For my better understanding:
> Can you explain me the real bug in 
> http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6881442.
> In my understanding, loading the "name" field twice is too only a 
> performance bug. Please correct me!

Class.getName() could in theory return null and this is not allowed, 
hence this was a functional correctness issue.

There are a few benevolent data-races in the JDK libs. I haven't looked 
at the Charset code so can't comment on whether or not it is benevolent.

David Holmes

>> I don't think it's worth a point fix here unless an actual wrong result
>> can be demonstrated.  I do think a more sophisticated charset cache
>> would be good, but hard to get right.
>>   
> 
> The other point is the size of the cache, see 
> http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6795535.
> I have logged the usage of the Charset.lookup() method from a simple 
> test which has only called ISO-8859-1 and IBM037 . As you can see, UTF-8 
> and cp1252 (default encoding on German Windows) is frequently requested 
> from the VM, so IMO size 2 is too restrictive (note the different 
> aliases UTF-8, utf-8 and UTF8):
> UTF-8
> utf-8
> UTF-8
> Cp1252
> UTF-8
> UTF-8
> UTF-8
> UTF-8
> UTF-8
> UTF-8
> UTF8
> UTF8
> Cp1252
> Cp1252
> Cp1252
> Cp1252
> Cp1252
> Cp1252
> Cp1252
> Cp1252
> Cp1252
> Cp1252
> Cp1252
> Cp1252
> UTF-8
> IBM037
> UTF-8
> UTF-8
> utf-8
> ISO-8859-1
> UTF-8
> 
> 
> -Ulf
> 
> 



More information about the core-libs-dev mailing list