jdk11u-dev icon indicating copy to clipboard operation
jdk11u-dev copied to clipboard

8269258: java/net/httpclient/ManyRequestsLegacy.java failed with connection timeout

Open amosshi opened this issue 1 year ago • 7 comments

Backport of JDK-8269258, a pre-required dependency to JDK-8327989

  • This PR contains 3 commits
  • Commit 1 - is the git apply from the original commit
  • Commit 2 - is the manual merge based on the .rej files. This commit can be considered as clean
    • ManyRequests.java.rej
    • ManyRequestsLegacy.java.rej
  • Commit 3 - converts the record type to class
    • Record type was added in Java 14 via JEP 359

Contents

  • ManyRequests.java.rej content
@@ -54,13 +55,18 @@
 import java.net.http.HttpClient.Builder;
 import java.net.http.HttpRequest;
 import java.net.http.HttpRequest.BodyPublishers;
+import java.net.http.HttpResponse;
 import java.net.http.HttpResponse.BodyHandlers;
 import java.time.Duration;
 import java.util.Arrays;
 import java.util.Formatter;
 import java.util.HashMap;
 import java.util.LinkedList;
+import java.util.Map;
 import java.util.Random;
+import java.util.concurrent.CompletionException;
+import java.util.concurrent.CompletionStage;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ThreadFactory;
@@ -100,14 +116,14 @@
     }
 
     //static final int REQUESTS = 1000;
-    static final int REQUESTS = 20;
+    static final int REQUESTS = MAX_COUNT;
     static final boolean INSERT_DELAY = Boolean.getBoolean("test.insertDelay");
     static final int CHUNK_SIZE = Math.max(0,
            Integer.parseInt(System.getProperty("test.chunkSize", "0")));
     static final boolean XFIXED = Boolean.getBoolean("test.XFixed");
 
     static class TestEchoHandler extends EchoHandler {
-        final Random rand = jdk.test.lib.RandomFactory.getRandom();
+        final Random rand = RANDOM;
         @Override
         public void handle(HttpExchange e) throws IOException {
             System.out.println("Server: received " + e.getRequestURI());
  • ManyRequestsLegacy.java.rej content
@@ -73,12 +80,20 @@
 import java.util.Random;
 import java.util.logging.Logger;
 import java.util.logging.Level;
+
+import jdk.test.lib.Platform;
+import jdk.test.lib.RandomFactory;
 import jdk.test.lib.net.SimpleSSLContext;
 import static java.net.Proxy.NO_PROXY;
 
 public class ManyRequestsLegacy {
 
-    volatile static int counter = 0;
+    static final int MAX_COUNT = 20;
+    static final int MAX_LIMIT = 40;
+    static final AtomicInteger COUNT = new AtomicInteger();
+    static final AtomicInteger LIMIT = new AtomicInteger(MAX_LIMIT);
+    static final Random RANDOM = RandomFactory.getRandom();
+
 
     public static void main(String[] args) throws Exception {
         Logger logger = Logger.getLogger("com.sun.net.httpserver");

Testing

  • Local: Test passed on MacOS 14.4.1
    • ManyRequests.java: Test results: passed: 1
    • ManyRequests2.java: Test results: passed: 1
    • ManyRequestsLegacy.java: Test results: passed: 1
  • Pipeline: All checks have passed
  • Testing Machine: SAP nightlies SKIPPED on 2024-05-02
    • Automated jtreg test: jtreg_jdk_tier2
    • java/net/httpclient/ManyRequests.java: SUCCESSFUL GitHub 📊⏲ - [62,025 msec]
    • java/net/httpclient/ManyRequests2.java: SUCCESSFUL GitHub 📊⏲ - [67,176 msec]
    • java/net/httpclient/ManyRequestsLegacy.java: SUCCESSFUL GitHub 📊⏲ - [48,737 msec]

Progress

  • [x] Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • [x] JDK-8269258 needs maintainer approval
  • [x] Change must not contain extraneous whitespace
  • [x] Commit message must refer to an issue

Issue

  • JDK-8269258: java/net/httpclient/ManyRequestsLegacy.java failed with connection timeout (Bug - P4 - Approved)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk11u-dev.git pull/2696/head:pull/2696
$ git checkout pull/2696

Update a local copy of the PR:
$ git checkout pull/2696
$ git pull https://git.openjdk.org/jdk11u-dev.git pull/2696/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 2696

View PR using the GUI difftool:
$ git pr show -t 2696

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk11u-dev/pull/2696.diff

Webrev

Link to Webrev Comment

amosshi avatar Apr 30 '24 21:04 amosshi

:wave: Welcome back ashi! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

bridgekeeper[bot] avatar Apr 30 '24 21:04 bridgekeeper[bot]

@amosshi This change now passes all automated pre-integration checks.

After integration, the commit message for the final commit will be:

8269258: java/net/httpclient/ManyRequestsLegacy.java failed with connection timeout

Reviewed-by: rrich

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 17 new commits pushed to the master branch:

  • c542dc913a765e9f7ab3ab47d51d5633f8716b9b: 8325579: Inconsistent behavior in com.sun.jndi.ldap.Connection::createSocket
  • 4202063c1b663cd0ed16209d54b257faf637cd08: 8293563: [macos-aarch64] SA core file tests failing with sun.jvm.hotspot.oops.UnknownOopException
  • b7822c39d323e470ea63289cf72c6a5ec43e6107: 8331643: [11u]: Bump GHA bootstrap JDK to 11.0.23
  • 3f636f30f9f040a8d320a4be7c2122fb22fd00bf: 8310818: Refactor more Locale tests to use JUnit
  • 1da8fd845cbed721ecc418d44573dd66743b639c: 8295343: sun/security/pkcs11 tests fail on Linux RHEL 8.6 and newer
  • cabaf7482681fb17cb7722377da6baab0ed2fed3: 8305931: jdk/jfr/jcmd/TestJcmdDumpPathToGCRoots.java failed with "Expected chains but found none"
  • 137a8b9dcfaad4a96dfd22f57c759dfc4ea71f05: 8308021: Update IANA Language Subtag Registry to Version 2023-05-11
  • d42634bdacb1b98cf3740f0fc73562385661f6ef: 8263940: NPE when creating default file system when default file system provider is packaged as JAR file on class path
  • 93630950c24d4e9c30507484aeecc91b6b57a584: 8328194: Add a test to check default rendering engine
  • 81f2413af5207fd52e23d26e33bc73dca96649a2: 8318809: java/util/concurrent/ConcurrentLinkedQueue/WhiteBox.java shows intermittent failures on linux ppc64le and aarch64
  • ... and 7 more: https://git.openjdk.org/jdk11u-dev/compare/f3d0f2bac0a01c992760826bc006f4f4c55584ed...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

openjdk[bot] avatar Apr 30 '24 21:04 openjdk[bot]

This backport pull request has now been updated with issue from the original commit.

openjdk[bot] avatar Apr 30 '24 21:04 openjdk[bot]

Webrevs

mlbridge[bot] avatar Apr 30 '24 21:04 mlbridge[bot]

⚠️ @amosshi This change is now ready for you to apply for maintainer approval. This can be done directly in each associated issue or by using the /approval command.

openjdk[bot] avatar May 07 '24 07:05 openjdk[bot]

/approval request "Un-Clean backport. No risk, test fix. SAP nightlies passed on 2024-05-02”

amosshi avatar May 07 '24 08:05 amosshi

@amosshi 8269258: The approval request has been created successfully.

openjdk[bot] avatar May 07 '24 08:05 openjdk[bot]

/integrate

amosshi avatar May 08 '24 06:05 amosshi

Going to push as commit 665e1cd4f976abf89a32c12a96642cbab2c5d157. Since your change was applied there have been 20 commits pushed to the master branch:

  • 4c81a1ca3856b76cd851cd236844765db468144c: 8283349: Robustness improvements to java/util/prefs/AddNodeChangeListener.jar
  • 6b225d5a632496431550ebd31379660384fc2eaf: 8253980: javax/swing/plaf/synth/7158712/bug7158712.java fails on windows
  • b9cb5721c999093aaf8e40677e2bac919dab879e: 8313702: Update IANA Language Subtag Registry to Version 2023-08-02
  • c542dc913a765e9f7ab3ab47d51d5633f8716b9b: 8325579: Inconsistent behavior in com.sun.jndi.ldap.Connection::createSocket
  • 4202063c1b663cd0ed16209d54b257faf637cd08: 8293563: [macos-aarch64] SA core file tests failing with sun.jvm.hotspot.oops.UnknownOopException
  • b7822c39d323e470ea63289cf72c6a5ec43e6107: 8331643: [11u]: Bump GHA bootstrap JDK to 11.0.23
  • 3f636f30f9f040a8d320a4be7c2122fb22fd00bf: 8310818: Refactor more Locale tests to use JUnit
  • 1da8fd845cbed721ecc418d44573dd66743b639c: 8295343: sun/security/pkcs11 tests fail on Linux RHEL 8.6 and newer
  • cabaf7482681fb17cb7722377da6baab0ed2fed3: 8305931: jdk/jfr/jcmd/TestJcmdDumpPathToGCRoots.java failed with "Expected chains but found none"
  • 137a8b9dcfaad4a96dfd22f57c759dfc4ea71f05: 8308021: Update IANA Language Subtag Registry to Version 2023-05-11
  • ... and 10 more: https://git.openjdk.org/jdk11u-dev/compare/f3d0f2bac0a01c992760826bc006f4f4c55584ed...master

Your commit was automatically rebased without conflicts.

openjdk[bot] avatar May 08 '24 06:05 openjdk[bot]

@amosshi Pushed as commit 665e1cd4f976abf89a32c12a96642cbab2c5d157.

:bulb: You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

openjdk[bot] avatar May 08 '24 06:05 openjdk[bot]