Codereview request for 6898310: (cs) Charset cache lookups should be synchronized

Ulf Zibis Ulf.Zibis at
Fri Sep 2 12:46:30 UTC 2011

Am 02.09.2011 13:34, schrieb Alan Bateman:
> Rémi Forax wrote:
>> Arghhh, next() can return null !
>> CharsetProvider provider = ...
>> Iterator<Charset> it = provider.charsets();
>> Iterator<Charset> it2 = provider.charsets();
>> Charset charset =;
>> provider.deleteCharset(, ...)
>> System.out.println(;   // print null
>> even if I'm not sure a lot of CharsetProvider actually calls deleteCharset
>> there is a possible bug here.
There is another sync nit on lookups. See the comments on:

> deleteCharset isn't a public method so I don't think this can happen. I don't disagree that that 
> the iterator code should be re-written, just thinking it's separate from fixing the race condition.

Yes, and there are more reasons to rewrite the AbstractCharsetProvider:

Instead _recoding_ an iterator for method charsets() you could simply use 
See example (Line 141 vs. 62):
For AbstractCharsetProvider (here renamed to ExternalCharsetProvider) See (Line 134):


More information about the core-libs-dev mailing list