--- a/test/jdk/java/net/httpclient/http2/Timeout.java Tue Apr 17 15:39:20 2018 +0200
+++ b/test/jdk/java/net/httpclient/http2/Timeout.java Tue Apr 17 08:54:17 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018, 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
@@ -23,19 +23,21 @@
import java.io.File;
import java.io.IOException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
import java.net.URI;
-import jdk.incubator.http.HttpClient;
-import jdk.incubator.http.HttpRequest;
-import jdk.incubator.http.HttpResponse;
-import jdk.incubator.http.HttpTimeoutException;
+import java.net.http.HttpClient;
+import java.net.http.HttpRequest;
+import java.net.http.HttpRequest.BodyPublishers;
+import java.net.http.HttpResponse;
+import java.net.http.HttpResponse.BodyHandlers;
+import java.net.http.HttpTimeoutException;
import java.time.Duration;
import java.util.concurrent.CompletionException;
import javax.net.ssl.SSLServerSocket;
import javax.net.ssl.SSLParameters;
import javax.net.ssl.SSLServerSocketFactory;
import javax.net.ssl.SSLSocket;
-import static jdk.incubator.http.HttpRequest.BodyPublisher.fromString;
-import static jdk.incubator.http.HttpResponse.BodyHandler.asString;
/*
* @test
@@ -69,7 +71,9 @@
(SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
try (SSLServerSocket ssocket =
- (SSLServerSocket) factory.createServerSocket(RANDOM_PORT)) {
+ (SSLServerSocket) factory.createServerSocket()) {
+ ssocket.setReuseAddress(false);
+ ssocket.bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), RANDOM_PORT));
// start server
Thread server = new Thread(() -> {
@@ -118,9 +122,9 @@
.build();
HttpRequest request = HttpRequest.newBuilder(new URI(server))
.timeout(Duration.ofMillis(TIMEOUT))
- .POST(fromString("body"))
+ .POST(BodyPublishers.ofString("body"))
.build();
- HttpResponse<String> response = client.send(request, asString());
+ HttpResponse<String> response = client.send(request, BodyHandlers.ofString());
System.out.println("Received unexpected reply: " + response.statusCode());
throw new RuntimeException("unexpected successful connection");
} catch (HttpTimeoutException e) {
@@ -135,9 +139,9 @@
.build();
HttpRequest request = HttpRequest.newBuilder(new URI(server))
.timeout(Duration.ofMillis(TIMEOUT))
- .POST(fromString("body"))
+ .POST(BodyPublishers.ofString("body"))
.build();
- HttpResponse<String> response = client.sendAsync(request, asString()).join();
+ HttpResponse<String> response = client.sendAsync(request, BodyHandlers.ofString()).join();
System.out.println("Received unexpected reply: " + response.statusCode());
throw new RuntimeException("unexpected successful connection");
} catch (CompletionException e) {