< prev index next >
test/jdk/java/net/httpclient/ManyRequests.java
Print this page
@@ -54,17 +54,16 @@
import java.util.Arrays;
import java.util.Formatter;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Random;
-import java.util.concurrent.ExecutorService;
import java.util.logging.Logger;
import java.util.logging.Level;
import java.util.concurrent.CompletableFuture;
import javax.net.ssl.SSLContext;
import jdk.testlibrary.SimpleSSLContext;
-import static jdk.incubator.http.HttpRequest.BodyProcessor.fromByteArray;
+import static jdk.incubator.http.HttpRequest.BodyPublisher.fromByteArray;
import static jdk.incubator.http.HttpResponse.BodyHandler.asByteArray;
public class ManyRequests {
volatile static int counter = 0;
@@ -89,11 +88,10 @@
try {
test(server, client);
System.out.println("OK");
} finally {
server.stop(0);
- ((ExecutorService)client.executor()).shutdownNow();
}
}
//static final int REQUESTS = 1000;
static final int REQUESTS = 20;
@@ -109,19 +107,21 @@
System.out.println("Server: received " + e.getRequestURI());
super.handle(e);
}
protected void close(OutputStream os) throws IOException {
if (INSERT_DELAY) {
- try { Thread.sleep(rand.nextInt(200)); } catch (InterruptedException e) {}
+ try { Thread.sleep(rand.nextInt(200)); }
+ catch (InterruptedException e) {}
}
- super.close(os);
+ os.close();
}
protected void close(InputStream is) throws IOException {
if (INSERT_DELAY) {
- try { Thread.sleep(rand.nextInt(200)); } catch (InterruptedException e) {}
+ try { Thread.sleep(rand.nextInt(200)); }
+ catch (InterruptedException e) {}
}
- super.close(is);
+ is.close();
}
}
static void test(HttpsServer server, HttpClient client) throws Exception {
int port = server.getAddress().getPort();
< prev index next >