On Fri, 2 Apr 2021 17:45:45 GMT, Anthony Scarpino <ascarp...@openjdk.org> wrote:

>> src/java.base/share/classes/sun/security/rsa/RSACore.java line 66:
>> 
>>> 64:     // like performance testing.
>>> 65:     private static final Map<BigInteger, 
>>> ConcurrentLinkedQueue<BlindingParameters>>
>>> 66:                 blindingCache = new WeakHashMap<>();
>> 
>> I'd use a synchronizedMap here now
>
> Using a synchronizedMap would only let one thread access the hashmap at a 
> time, which is what I'm trying to reduce.  Get ops do not need to be locked 
> and put ops don't either because the values are objects of random data, 
> losing one is not significant to the operation.

According to SO, unsynchronized writes to a map can lead to lock up, see here:
https://stackoverflow.com/a/1003237
Or here:
https://mailinator.blogspot.com/2009/06/beautiful-race-condition.html?m=1
What's the performance impact of adding synchronization on the hash map only?

-------------

PR: https://git.openjdk.java.net/jdk/pull/3296

Reply via email to