Skip to content

Commit 59ffac8

Browse files
vydfuch
authored andcommitted
8342811: java/net/httpclient/PlainProxyConnectionTest.java failed: Unexpected connection count: 5
Reviewed-by: dfuchs
1 parent f316808 commit 59ffac8

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

test/jdk/java/net/httpclient/PlainProxyConnectionTest.java

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
2525
import com.sun.net.httpserver.HttpExchange;
2626
import com.sun.net.httpserver.HttpHandler;
2727
import com.sun.net.httpserver.HttpServer;
28+
import jdk.httpclient.test.lib.common.HttpServerAdapters;
29+
2830
import java.io.IOException;
2931
import java.io.InputStream;
3032
import java.net.HttpURLConnection;
@@ -54,15 +56,28 @@
5456
* @bug 8230526
5557
* @summary Verifies that PlainProxyConnections are cached and reused properly. We do this by
5658
* verifying that the remote address of the HTTP exchange (on the fake proxy server)
57-
* is always the same InetSocketAddress.
58-
* @modules jdk.httpserver
59-
* @run main/othervm -Djdk.tracePinnedThreads=full PlainProxyConnectionTest
60-
* @author danielfuchs
59+
* is always the same InetSocketAddress. Logging verbosity is increased to aid in
60+
* diagnosis of intermittent failures.
61+
* @library /test/lib
62+
* /test/jdk/java/net/httpclient/lib
63+
* @run main/othervm -Djdk.tracePinnedThreads=full
64+
* -Djdk.httpclient.HttpClient.log=headers,requests,trace
65+
* -Djdk.internal.httpclient.debug=true
66+
* PlainProxyConnectionTest
6167
*/
6268
public class PlainProxyConnectionTest {
6369

70+
// Increase logging verbosity to troubleshoot intermittent failures
71+
static {
72+
HttpServerAdapters.enableServerLogging();
73+
}
74+
6475
static final String RESPONSE = "<html><body><p>Hello World!</body></html>";
65-
static final String PATH = "/foo/";
76+
77+
// Adding some salt to the path to avoid other parallel running tests mistakenly connect to our test server
78+
private static final String PATH = String.format(
79+
"/%s-%d", PlainProxyConnectionTest.class.getSimpleName(), PlainProxyConnectionTest.class.hashCode());
80+
6681
static final ConcurrentLinkedQueue<InetSocketAddress> connections = new ConcurrentLinkedQueue<>();
6782
private static final AtomicInteger IDS = new AtomicInteger();
6883

0 commit comments

Comments
 (0)