RFR: 8361249: PlainHttpConnection connection logic can be simplified

Daniel Fuchs dfuchs at openjdk.org
Thu Jul 3 12:59:40 UTC 2025


On Thu, 3 Jul 2025 10:49:21 GMT, Volkan Yazici <vyazici at openjdk.org> wrote:

>> The PlainHttpConnection::connectAsync method implements a retry logic that will call connect() again if connect() throws the first time. This will not work, as the channel is closed when connect() throws. That logic should be removed. Reconnection should only be attempted at a higher level (MultiExchange).
>
> src/java.net.http/share/classes/jdk/internal/net/http/PlainHttpConnection.java line 1:
> 
>> 1: /*
> 
> Shouldn't we remove the following too?
> 
> 1. The `unsuccessfulAttempts` field
> 2. `jdk.internal.net.http.common.TimeSource` import

Good point.

> src/java.net.http/share/classes/jdk/internal/net/http/PlainHttpConnection.java line 232:
> 
>> 230:         }
>> 231:         return cf.thenApply((state)->{
>> 232:             if (debug.on()) debug.log("%s: %s", label(), state);
> 
> AFAICT, this is the only place where a `ConnectState` is _read_. Alternatively, we can remove the `ConnectState` enum and add `debug.log()` statements where `ConnectState` were assigned.

I know. I hesitated and eventually decided to keep it.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/26087#discussion_r2182716896
PR Review Comment: https://git.openjdk.org/jdk/pull/26087#discussion_r2182718272


More information about the net-dev mailing list