RFR: 7113878: LogManager - namedLoggers should be ConcurrentHashMap instead of Hashtable

Peter Levart peter.levart at gmail.com
Thu Mar 26 13:43:34 UTC 2015


On 03/26/2015 01:28 PM, 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?
>
> David

Hi Daniel,

...or, if you keep CHM, you might be able to use it for a benefit.

You say that retrieving a logger by name is the most frequent operation. 
If you can prove that moving a statement in addLocalLogger method that 
publishes the Logger via CHM to the end of synchronized block without 
hurting the logic that exists in-between and initializes the Logger 
instance, then you can implement the findLogger method in a way that 
almost never needs to enter synchronized block:

http://cr.openjdk.java.net/~plevart/jdk9-dev/LogManager.CHM/webrev.01/

Regards, Peter

>
>> 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