--- a/test/jdk/java/net/httpclient/http2/BasicTest.java Wed Nov 29 16:34:52 2017 +0000
+++ b/test/jdk/java/net/httpclient/http2/BasicTest.java Wed Nov 29 16:59:38 2017 +0000
@@ -93,21 +93,23 @@
static List<CompletableFuture<Long>> cfs = Collections
.synchronizedList( new LinkedList<>());
- static AtomicReference<CompletableFuture<Long>> currentCF =
- new AtomicReference<>();
+ static CompletableFuture<Long> currentCF;
static class EchoWithPingHandler extends Http2EchoHandler {
+ private final Object lock = new Object();
+
@Override
public void handle(Http2TestExchange exchange) throws IOException {
- // ensure only one ping active at a time.
- currentCF.getAndUpdate((cf) -> {
- if (cf == null || cf.isDone()) {
+ // for now only one ping active at a time. don't want to saturate
+ synchronized(lock) {
+ CompletableFuture<Long> cf = currentCF;
+ if (cf == null || cf.isDone()) {
cf = exchange.sendPing();
assert cf != null;
cfs.add(cf);
+ currentCF = cf;
}
- return cf;
- });
+ }
super.handle(exchange);
}
}
@@ -122,7 +124,6 @@
streamTest(false);
streamTest(true);
paramsTest();
- Thread.sleep(1000 * 4);
CompletableFuture.allOf(cfs.toArray(new CompletableFuture[0])).join();
synchronized (cfs) {
for (CompletableFuture<Long> cf : cfs) {