Skip to content

Commit 005b8b9

Browse files
committed
8217882: java/net/httpclient/MaxStreams.java failed once
Added some more traces to help diagnosis Backport-of: 6dcfd0f
1 parent a13296f commit 005b8b9

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

test/jdk/java/net/httpclient/MaxStreams.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -105,6 +105,7 @@ public Object[][] variants() {
105105

106106
@Test(dataProvider = "uris", timeOut=20000)
107107
void testAsString(String uri) throws Exception {
108+
System.err.println("Semaphore acquire");
108109
canStartTestRun.acquire();
109110
latch = new CountDownLatch(1);
110111
handler.setLatch(latch);
@@ -116,16 +117,19 @@ void testAsString(String uri) throws Exception {
116117
.GET()
117118
.build();
118119
// send warmup to ensure we only have one Http2Connection
120+
System.err.println("Sending warmup request");
119121
HttpResponse<String> warmup = client.send(request, BodyHandlers.ofString());
120122
if (warmup.statusCode() != 200 || !warmup.body().equals(RESPONSE))
121123
throw new RuntimeException();
122124

123125
for (int i=0;i<MAX_STREAMS+1; i++) {
126+
System.err.println("Sending request " + i);
124127
responses.add(client.sendAsync(request, BodyHandlers.ofString()));
125128
}
126129

127130
// wait until we get local exception before allow server to proceed
128131
try {
132+
System.err.println("Waiting for first exception");
129133
CompletableFuture.anyOf(responses.toArray(new CompletableFuture<?>[0])).join();
130134
} catch (Exception ee) {
131135
System.err.println("Expected exception 1 " + ee);
@@ -135,6 +139,7 @@ void testAsString(String uri) throws Exception {
135139

136140
// check the first MAX_STREAMS requests succeeded
137141
try {
142+
System.err.println("Waiting for second exception");
138143
CompletableFuture.allOf(responses.toArray(new CompletableFuture<?>[0])).join();
139144
System.err.println("Did not get Expected exception 2 ");
140145
} catch (Exception ee) {
@@ -161,6 +166,7 @@ void testAsString(String uri) throws Exception {
161166
throw new RuntimeException(msg);
162167
}
163168

169+
System.err.println("Sending last request");
164170
// make sure it succeeds now as number of streams == 0 now
165171
HttpResponse<String> warmdown = client.send(request, BodyHandlers.ofString());
166172
if (warmdown.statusCode() != 200 || !warmdown.body().equals(RESPONSE))
@@ -183,8 +189,8 @@ public void setup() throws Exception {
183189
http2TestServer.start();
184190

185191
https2TestServer = new Http2TestServer("localhost", true, 0, exec, 10, props, ctx);
186-
https2TestServer.addHandler(handler, "/http2/fixed");
187-
https2FixedURI = "https://" + https2TestServer.serverAuthority()+ "/http2/fixed";
192+
https2TestServer.addHandler(handler, "/https2/fixed");
193+
https2FixedURI = "https://" + https2TestServer.serverAuthority()+ "/https2/fixed";
188194
https2TestServer.start();
189195
}
190196

@@ -196,7 +202,7 @@ public void teardown() throws Exception {
196202

197203
class Http2FixedHandler implements Http2Handler {
198204
final AtomicInteger counter = new AtomicInteger(0);
199-
CountDownLatch latch;
205+
volatile CountDownLatch latch;
200206

201207
synchronized void setLatch(CountDownLatch latch) {
202208
this.latch = latch;
@@ -218,9 +224,9 @@ public void handle(Http2TestExchange t) throws IOException {
218224
// Wait for latch.
219225
try {
220226
// don't send any replies until all requests are sent
221-
System.err.println("latch await");
227+
System.err.println("Latch await");
222228
getLatch().await();
223-
System.err.println("latch resume");
229+
System.err.println("Latch resume");
224230
} catch (InterruptedException ee) {}
225231
}
226232
t.sendResponseHeaders(200, RESPONSE.length());
@@ -230,6 +236,7 @@ public void handle(Http2TestExchange t) throws IOException {
230236
// but server should only see MAX_STREAMS + 2 in total. One is rejected by client
231237
// counter c captured before increment so final value is MAX_STREAMS + 1
232238
if (c == MAX_STREAMS + 1) {
239+
System.err.println("Semaphore release");
233240
counter.set(0);
234241
canStartTestRun.release();
235242
}

0 commit comments

Comments
 (0)