RFR: 8304818: Prune HttpURLConnection cache when corresponding Authenticator is garbage collected
Daniel Fuchs
dfuchs at openjdk.org
Fri Mar 24 14:46:34 UTC 2023
On Fri, 24 Mar 2023 13:11:00 GMT, Daniel Jeliński <djelinski at openjdk.org> wrote:
>> Hi,
>>
>> Can I get a review for this please? This change uses a Cleaner to check when java.net.Authenticator instances become unreachable, and then prunes the authentication cache for entries that correspond to that Authenticator and therefore cannot be used again. This stops the authentication cache from growing in size unbounded. Note, this only happens in the probably unusual case where more than one Authenticator object is used. Normally there is no reason to use more than one instance.
>>
>> Thanks,
>> Michael.
>
> src/java.base/share/classes/sun/net/www/protocol/http/AuthCacheImpl.java line 85:
>
>> 83: LinkedList<AuthCacheValue> list) -> {
>> 84: if (key.endsWith(authkey)) {
>> 85: hashtable.remove(key);
>
> won't this throw a `ConcurrentModificationException`?
That's a good point. One solution would be to use a ConcurrentHashMap instead of a simple HashMap.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13159#discussion_r1147679359
More information about the net-dev
mailing list