RFR: 7113878: LogManager - namedLoggers should be ConcurrentHashMap instead of Hashtable
Jason Mehrens
jason_mehrens at hotmail.com
Thu Mar 26 13:42:25 UTC 2015
The snapshot enumeration is a welcomed change. ConcurrentHashMap has legacy Hashtable methods so you can save a little bit by calling namedLoggers.keys() instead of wrapping the key set.
Jason
----------------------------------------
> Date: Thu, 26 Mar 2015 14:32:23 +0100
> From: daniel.fuchs at oracle.com
> To: david.holmes at oracle.com; core-libs-dev at openjdk.java.net
> Subject: Re: RFR: 7113878: LogManager - namedLoggers should be ConcurrentHashMap instead of Hashtable
>
> On 26/03/15 13:28, David Holmes wrote:
>> Hi Daniel,
>>
>> On 26/03/2015 10:08 PM, Daniel Fuchs wrote:
>>> Please find below a trivial fix for
>>>
>>>
>>> 7113878: LogManager - namedLoggers should be ConcurrentHashMap
>>> instead of Hashtable
>>
>> As you say in the bug report, now that the map is always accessed within
>> synchronized code this serves no purpose. The map not only doesn't need
>> to be concurrent, it doesn't even need to be thread-safe! So why not
>> replace with a simple HashMap?
>
> You found me out ;-) I should have mentioned it.
> The enumeration of keys returned from the map will be iterated
> outside of any synchronized block.
> ConcurrentHashMap makes this safe.
>
> best regards,
>
> -- daniel
>
>
>>
>> David
>>
>>> https://bugs.openjdk.java.net/browse/JDK-7113878
>>>
>>> http://cr.openjdk.java.net/~dfuchs/webrev_7113878/webrev.00
>>>
>>> best regards,
>>>
>>> -- daniel
>
More information about the core-libs-dev
mailing list