RFR: 8304818: Prune HttpURLConnection cache when corresponding Authenticator is garbage collected [v9]

Daniel Fuchs dfuchs at openjdk.org
Wed Apr 12 11:53:37 UTC 2023


On Wed, 12 Apr 2023 11:08:56 GMT, Michael McMahon <michaelm 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.
>
> Michael McMahon has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - error in test
>  - Jai's review

src/java.base/share/classes/sun/net/www/protocol/http/AuthCacheImpl.java line 126:

> 124:             }
> 125:             return c;
> 126:         }

Suggestion:

        return caches.computeIfAbsent(auth, (k) -> new AuthCacheImpl());

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

PR Review Comment: https://git.openjdk.org/jdk/pull/13159#discussion_r1164019776


More information about the net-dev mailing list