8217914: java/net/httpclient/ConnectTimeoutHandshakeSync.java failed on connection refused while doing POST

Reviewed-by: dfuchs, jpai
This commit is contained in:
Volkan Yazıcı
2025-01-20 06:53:25 +00:00
committed by Jaikiran Pai
parent 644d154c7c
commit e7a1c8660a
3 changed files with 16 additions and 11 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2025, 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
@@ -44,10 +44,11 @@ import java.net.http.HttpRequest;
import java.net.http.HttpRequest.BodyPublishers;
import java.net.http.HttpResponse;
import java.net.http.HttpResponse.BodyHandlers;
import jdk.test.lib.net.URIBuilder;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.DataProvider;
import static java.lang.String.format;
import static java.lang.System.out;
import static java.net.http.HttpClient.Builder.NO_PROXY;
import static java.net.http.HttpClient.Version.HTTP_1_1;
@@ -56,7 +57,7 @@ import static java.time.Duration.*;
import static java.util.concurrent.TimeUnit.NANOSECONDS;
import static org.testng.Assert.fail;
public abstract class AbstractConnectTimeoutHandshake {
abstract class AbstractConnectTimeoutHandshake {
// The number of iterations each testXXXClient performs.
static final int TIMES = 2;
@@ -197,15 +198,15 @@ public abstract class AbstractConnectTimeoutHandshake {
// -- Infrastructure
static String serverAuthority(Server server) {
return InetAddress.getLoopbackAddress().getHostName() + ":"
+ server.getPort();
}
@BeforeTest
public void setup() throws Exception {
server = new Server();
httpsURI = URI.create("https://" + serverAuthority(server) + "/foo");
httpsURI = URIBuilder.newBuilder()
.scheme("https")
.loopback()
.port(server.getPort())
.path("/foo")
.build();
out.println("HTTPS URI: " + httpsURI);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2025, 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
@@ -29,6 +29,8 @@ import org.testng.annotations.Test;
* @test
* @summary Tests connection timeouts during SSL handshake
* @bug 8208391
* @library /test/lib
* @build AbstractConnectTimeoutHandshake
* @run testng/othervm ConnectTimeoutHandshakeAsync
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2025, 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
@@ -29,6 +29,8 @@ import org.testng.annotations.Test;
* @test
* @summary Tests connection timeouts during SSL handshake
* @bug 8208391
* @library /test/lib
* @build AbstractConnectTimeoutHandshake
* @run testng/othervm ConnectTimeoutHandshakeSync
*/