[jdk11u-dev] RFR: 8269258: java/net/httpclient/ManyRequestsLegacy.java failed with connection timeout
Richard Reingruber
rrich at openjdk.org
Tue May 7 07:58:01 UTC 2024
On Tue, 30 Apr 2024 21:44:04 GMT, Amos Shi <ashi at openjdk.org> wrote:
> Backport of [JDK-8269258](https://bugs.openjdk.org/browse/JDK-8269258), a pre-required dependency to [JDK-8327989](https://bugs.openjdk.org/browse/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 = ...
Looks good to me.
Cheers, Richard.
-------------
Marked as reviewed by rrich (Reviewer).
PR Review: https://git.openjdk.org/jdk11u-dev/pull/2696#pullrequestreview-2042358307
More information about the jdk-updates-dev
mailing list