RFR JDK-8187653: Lock in CoderResult.Cache becomes performance bottleneck

Xueming Shen xueming.shen at oracle.com
Fri Mar 2 02:09:29 UTC 2018

On 3/1/18, 4:35 PM, David Holmes wrote:

> When you replace synchronized code with concurrent data structures you 
> introduce race conditions that are precluded in the synchronized code. 
> These need to be examined carefully to ensure they are safe. For 
> example, whenever you replace a HashMap with a ConcurrentHashMap you 
> need to see if put() needs to be replaced by putIfAbsent().

Hi David,

The assumption here is that putIfAbsent() does not help/save anything as 
the value object
would have been created already when it reaches here. And it appears 
there is no need here
to have the check&put to be atomic, replacing any existing key/value 
pair is fine in this use
scenario.  Was thinking about computIfAbsent(), but concluded it's just 
little overdone (wonder
why we decided to use the WeakReference in this case, it probably is not 
worth it, but keep it as
is for "compatibility" concern).


More information about the core-libs-dev mailing list