Skip to content

Commit

Permalink
8256459: java/net/httpclient/ManyRequests.java and java/net/httpclien…
Browse files Browse the repository at this point in the history
…t/LineBodyHandlerTest.java fail infrequently with java.net.ConnectException: Connection timed out: no further information

Connect will not be retried if retry connect is disabled
JBS issue label noreg-self removed and bug id added to tests
  • Loading branch information
dfuch committed Dec 9, 2020
1 parent 617c1f5 commit 090b390
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
Expand Up @@ -471,7 +471,7 @@ private static boolean disableRetryConnect() {
/** True if ALL ( even non-idempotent ) requests can be automatic retried. */
private static final boolean RETRY_ALWAYS = retryPostValue();
/** True if ConnectException should cause a retry. Enabled by default */
private static final boolean RETRY_CONNECT = !disableRetryConnect();
static final boolean RETRY_CONNECT = !disableRetryConnect();

/** Returns true is given request has an idempotent method. */
private static boolean isIdempotentRequest(HttpRequest request) {
Expand Down
Expand Up @@ -61,9 +61,10 @@ class PlainHttpConnection extends HttpConnection {
private volatile ConnectTimerEvent connectTimerEvent; // may be null
private volatile int unsuccessfulAttempts;

private enum ConnectState {
SUCCESS, RETRY
}
// Indicates whether a connection attempt has succeeded or should be retried.
// If the attempt failed, and shouldn't be retried, there will be an exception
// instead.
private enum ConnectState { SUCCESS, RETRY }


/**
Expand Down Expand Up @@ -233,6 +234,7 @@ private CompletableFuture<Void> checkRetryConnect(ConnectState connect, Throwabl
}

private boolean canRetryConnect(Throwable e) {
if (!MultiExchange.RETRY_CONNECT) return false;
if (!(e instanceof ConnectException)) return false;
if (unsuccessfulAttempts > 0) return false;
ConnectTimerEvent timer = connectTimerEvent;
Expand Down
3 changes: 2 additions & 1 deletion test/jdk/java/net/httpclient/LineBodyHandlerTest.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -76,6 +76,7 @@
* @summary Basic tests for line adapter subscribers as created by
* the BodyHandlers returned by BodyHandler::fromLineSubscriber
* and BodyHandler::asLines
* @bug 8256459
* @modules java.base/sun.net.www.http
* java.net.http/jdk.internal.net.http.common
* java.net.http/jdk.internal.net.http.frame
Expand Down
4 changes: 2 additions & 2 deletions test/jdk/java/net/httpclient/ManyRequests.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -23,7 +23,7 @@

/*
* @test
* @bug 8087112 8180044
* @bug 8087112 8180044 8256459
* @modules java.net.http
* java.logging
* jdk.httpserver
Expand Down
4 changes: 2 additions & 2 deletions test/jdk/java/net/httpclient/ManyRequests2.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -23,7 +23,7 @@

/*
* @test
* @bug 8087112 8180044
* @bug 8087112 8180044 8256459
* @modules java.net.http
* java.logging
* jdk.httpserver
Expand Down

0 comments on commit 090b390

Please sign in to comment.