On Thu, 5 Feb 2026 02:13:38 GMT, Artur Barashev <[email protected]> wrote:

>> src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java line 236:
>> 
>>> 234:         return compCertCache;
>>> 235:     }
>>> 236: 
>> 
>> Thank you for the update, @artur-oracle!   As sslContext instance are 
>> normally run in multiple threads context, could cache operation 
>> synchronization be a concern?
>
> I considered synchronization but I don't think it's really needed, the 
> situation is the same as with cache being static actually:
> 
> - `SoftMemoryCache` being used is already synchronized internally for `get` 
> and `put` operations.
> -  Race condition is possible in between `get` and `put` operations in 
> `CompressedCertProducer`, but the worst that can happen is that we compress 
> and insert the same certMsg into cache twice. Not something worth locking the 
> whole cache while we compress IMO.
> - I chose `SoftMemoryCache` over `ConcurrentHashMap` because of LRU and soft 
> reference mechanisms. Otherwise the former provides finer per-bucket 
> synchronization and atomic `computeIfAbsent` call.

Make sense to me. Thank you @artur-oracle!

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

PR Review Comment: https://git.openjdk.org/jdk/pull/28682#discussion_r2766962306

Reply via email to