8304818: Prune HttpURLConnection cache when corresponding Authenticator is garbage collected

Reviewed-by: dfuchs, djelinski
This commit is contained in:
Michael McMahon 2023-04-24 17:25:32 +00:00
parent 6b81342c22
commit 314db55f6d
18 changed files with 340 additions and 680 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,8 +25,6 @@
package java.net;
import sun.net.www.protocol.http.AuthenticatorKeys;
/**
* The class Authenticator represents an object that knows how to obtain
* authentication for a network connection. Usually, it will do this
@ -72,7 +70,6 @@ class Authenticator {
private String requestingScheme;
private URL requestingURL;
private RequestorType requestingAuthType;
private final String key = AuthenticatorKeys.computeKey(this);
/**
* Constructor for subclasses to call.
@ -576,11 +573,4 @@ class Authenticator {
protected RequestorType getRequestorType () {
return requestingAuthType;
}
static String getKey(Authenticator a) {
return a.key;
}
static {
AuthenticatorKeys.setAuthenticatorKeyAccess(Authenticator::getKey);
}
}