8251361: Potential race between Logger configuration and GCs in HttpURLConWithProxy test
Keep a static reference to the logger to prevent its inadvertent garbage collection while the test is running. Reviewed-by: dfuchs
This commit is contained in:
parent
688e5d9071
commit
ed5696dd2c
@ -48,17 +48,21 @@ import java.util.logging.LogRecord;
|
|||||||
|
|
||||||
public class HttpURLConWithProxy {
|
public class HttpURLConWithProxy {
|
||||||
|
|
||||||
|
private static Logger logger =
|
||||||
|
Logger.getLogger("sun.net.www.protocol.http.HttpURLConnection");
|
||||||
|
|
||||||
public static void main(String... arg) throws Exception {
|
public static void main(String... arg) throws Exception {
|
||||||
// Remove the default nonProxyHosts to use localhost for testing
|
// Remove the default nonProxyHosts to use localhost for testing
|
||||||
System.setProperty("http.nonProxyHosts", "");
|
System.setProperty("http.nonProxyHosts", "");
|
||||||
|
|
||||||
System.setProperty("http.proxyHost", "1.1.1.1");
|
System.setProperty("http.proxyHost", "1.1.1.1");
|
||||||
System.setProperty("http.proxyPort", "1111");
|
System.setProperty("http.proxyPort", "1111");
|
||||||
String HTTPLOG = "sun.net.www.protocol.http.HttpURLConnection";
|
|
||||||
Logger.getLogger(HTTPLOG).setLevel(Level.ALL);
|
// Use the logger to help verify the Proxy was used
|
||||||
|
logger.setLevel(Level.ALL);
|
||||||
Handler h = new ProxyHandler();
|
Handler h = new ProxyHandler();
|
||||||
h.setLevel(Level.ALL);
|
h.setLevel(Level.ALL);
|
||||||
Logger.getLogger(HTTPLOG).addHandler(h);
|
logger.addHandler(h);
|
||||||
|
|
||||||
ServerSocket ss;
|
ServerSocket ss;
|
||||||
URL url;
|
URL url;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user