Skip to content

Commit

Permalink
8223696: java/net/httpclient/MaxStreams.java failed with didn't finis…
Browse files Browse the repository at this point in the history
…h within the time-out

Reviewed-by: dfuchs
  • Loading branch information
djelinski committed Jan 25, 2024
1 parent 39b756a commit 95310ea
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions test/jdk/java/net/httpclient/MaxStreams.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @summary Should HttpClient support SETTINGS_MAX_CONCURRENT_STREAMS from the server
* @library /test/lib /test/jdk/java/net/httpclient/lib
* @build jdk.httpclient.test.lib.http2.Http2TestServer jdk.test.lib.net.SimpleSSLContext
* @run testng/othervm -ea -esa MaxStreams
* @run testng/othervm MaxStreams
*/

import java.io.IOException;
Expand All @@ -44,7 +44,6 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executors;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Semaphore;
import javax.net.ssl.SSLContext;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
Expand All @@ -71,9 +70,7 @@ public class MaxStreams {
SSLContext ctx;
String http2FixedURI;
String https2FixedURI;
volatile CountDownLatch latch;
ExecutorService exec;
final Semaphore canStartTestRun = new Semaphore(1);

// we send an initial warm up request, then MAX_STREAMS+1 requests
// in parallel. The last of them should hit the limit.
Expand All @@ -95,11 +92,9 @@ public Object[][] variants() {
}


@Test(dataProvider = "uris", timeOut=20000)
@Test(dataProvider = "uris")
void testAsString(String uri) throws Exception {
System.err.println("Semaphore acquire");
canStartTestRun.acquire();
latch = new CountDownLatch(1);
CountDownLatch latch = new CountDownLatch(1);
handler.setLatch(latch);
HttpClient client = HttpClient.newBuilder().sslContext(ctx).build();
List<CompletableFuture<HttpResponse<String>>> responses = new LinkedList<>();
Expand Down Expand Up @@ -206,12 +201,11 @@ synchronized CountDownLatch getLatch() {

@Override
public void handle(Http2TestExchange t) throws IOException {
int c = -1;
try (InputStream is = t.getRequestBody();
OutputStream os = t.getResponseBody()) {

is.readAllBytes();
c = counter.getAndIncrement();
int c = counter.getAndIncrement();
if (c > 0 && c <= MAX_STREAMS) {
// Wait for latch.
try {
Expand All @@ -220,18 +214,15 @@ public void handle(Http2TestExchange t) throws IOException {
getLatch().await();
System.err.println("Latch resume");
} catch (InterruptedException ee) {}
} else if (c == MAX_STREAMS + 1) {
// client issues MAX_STREAMS + 3 requests in total
// but server should only see MAX_STREAMS + 2 in total. One is rejected by client
// counter c captured before increment so final value is MAX_STREAMS + 1
System.err.println("Counter reset");
counter.set(0);
}
t.sendResponseHeaders(200, RESPONSE.length());
os.write(RESPONSE.getBytes());
} finally {
// client issues MAX_STREAMS + 3 requests in total
// but server should only see MAX_STREAMS + 2 in total. One is rejected by client
// counter c captured before increment so final value is MAX_STREAMS + 1
if (c == MAX_STREAMS + 1) {
System.err.println("Semaphore release");
counter.set(0);
canStartTestRun.release();
}
}
}
}
Expand Down

5 comments on commit 95310ea

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GoeLin
Copy link
Member

@GoeLin GoeLin commented on 95310ea Mar 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk21u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 95310ea Mar 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GoeLin the backport was successfully created on the branch backport-GoeLin-95310eab in my personal fork of openjdk/jdk21u-dev. To create a pull request with this backport targeting openjdk/jdk21u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 95310eab from the openjdk/jdk repository.

The commit being backported was authored by Daniel Jeliński on 25 Jan 2024 and was reviewed by Daniel Fuchs.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21u-dev:

$ git fetch https://github.com/openjdk-bots/jdk21u-dev.git backport-GoeLin-95310eab:backport-GoeLin-95310eab
$ git checkout backport-GoeLin-95310eab
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk21u-dev.git backport-GoeLin-95310eab

@GoeLin
Copy link
Member

@GoeLin GoeLin commented on 95310ea Apr 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 95310ea Apr 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GoeLin the backport was successfully created on the branch backport-GoeLin-95310eab in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 95310eab from the openjdk/jdk repository.

The commit being backported was authored by Daniel Jeliński on 25 Jan 2024 and was reviewed by Daniel Fuchs.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev.git backport-GoeLin-95310eab:backport-GoeLin-95310eab
$ git checkout backport-GoeLin-95310eab
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev.git backport-GoeLin-95310eab

Please sign in to comment.