Skip to content
Snippets Groups Projects
Commit 32852925 authored by Darragh Clarke's avatar Darragh Clarke Committed by Severin Gehwolf
Browse files

8308336: Test...

8308336: Test java/net/HttpURLConnection/HttpURLConnectionExpectContinueTest.java failed: java.net.BindException: Address already in use

Backport-of: a48bcf367120fc7cde88b19097dabe9c86c90bb7
parent b27d63fc
No related branches found
No related tags found
No related merge requests found
...@@ -27,8 +27,11 @@ ...@@ -27,8 +27,11 @@
* @summary Verify that expect 100-continue doesn't hang * @summary Verify that expect 100-continue doesn't hang
* @library /test/lib * @library /test/lib
* @run junit/othervm HttpURLConnectionExpectContinueTest * @run junit/othervm HttpURLConnectionExpectContinueTest
* @run junit/othervm -Djava.net.preferIPv4Stack=true HttpURLConnectionExpectContinueTest
* @run junit/othervm -Djava.net.preferIPv6Addresses=true HttpURLConnectionExpectContinueTest
*/ */
import jdk.test.lib.net.URIBuilder;
import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
...@@ -73,7 +76,7 @@ public class HttpURLConnectionExpectContinueTest { ...@@ -73,7 +76,7 @@ public class HttpURLConnectionExpectContinueTest {
control.serverSocket = new ServerSocket(); control.serverSocket = new ServerSocket();
control.serverSocket.setReuseAddress(true); control.serverSocket.setReuseAddress(true);
control.serverSocket.bind(new InetSocketAddress("127.0.0.1", 54321)); control.serverSocket.bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
Runnable runnable = () -> { Runnable runnable = () -> {
while (!control.stop) { while (!control.stop) {
try { try {
...@@ -419,8 +422,12 @@ public class HttpURLConnectionExpectContinueTest { ...@@ -419,8 +422,12 @@ public class HttpURLConnectionExpectContinueTest {
} }
// Creates a connection with all the common settings used in each test // Creates a connection with all the common settings used in each test
private HttpURLConnection createConnection() throws IOException { private HttpURLConnection createConnection() throws Exception {
URL url = new URL("http://localhost:" + control.serverSocket.getLocalPort()); URL url = URIBuilder.newBuilder()
.scheme("http")
.loopback()
.port(control.serverSocket.getLocalPort())
.toURL();
HttpURLConnection connection = (HttpURLConnection) url.openConnection(); HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true); connection.setDoOutput(true);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment