Skip to content

Commit 21f2c1b

Browse files
committed
8342811: java/net/httpclient/PlainProxyConnectionTest.java failed: Unexpected connection count: 5
Reviewed-by: rrich Backport-of: 59ffac84d39250623b0e6bcb871b5b3fe9c9cfe6
1 parent 1da0179 commit 21f2c1b

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, 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;
@@ -51,15 +53,28 @@
5153
* @bug 8230526
5254
* @summary Verifies that PlainProxyConnections are cached and reused properly. We do this by
5355
* verifying that the remote address of the HTTP exchange (on the fake proxy server)
54-
* is always the same InetSocketAddress.
55-
* @modules jdk.httpserver
56-
* @run main/othervm PlainProxyConnectionTest
57-
* @author danielfuchs
56+
* is always the same InetSocketAddress. Logging verbosity is increased to aid in
57+
* diagnosis of intermittent failures.
58+
* @library /test/lib
59+
* /test/jdk/java/net/httpclient/lib
60+
* @run main/othervm
61+
* -Djdk.httpclient.HttpClient.log=headers,requests,trace
62+
* -Djdk.internal.httpclient.debug=true
63+
* PlainProxyConnectionTest
5864
*/
5965
public class PlainProxyConnectionTest {
6066

67+
// Increase logging verbosity to troubleshoot intermittent failures
68+
static {
69+
HttpServerAdapters.enableServerLogging();
70+
}
71+
6172
static final String RESPONSE = "<html><body><p>Hello World!</body></html>";
62-
static final String PATH = "/foo/";
73+
74+
// Adding some salt to the path to avoid other parallel running tests mistakenly connect to our test server
75+
private static final String PATH = String.format(
76+
"/%s-%d", PlainProxyConnectionTest.class.getSimpleName(), PlainProxyConnectionTest.class.hashCode());
77+
6378
static final ConcurrentLinkedQueue<InetSocketAddress> connections = new ConcurrentLinkedQueue<>();
6479

6580
// For convenience the server is used both as a plain server and as a plain proxy.

0 commit comments

Comments
 (0)