pg.ddx.io  GitHub: pgjdbc/pgjdbc (issues + PRs as email threads)  
help / color / mirror / Atom feed
From: vlsi (@vlsi) <noreply+vlsi@github.com>
To: pgjdbc/pgjdbc <noreply+pgjdbc-pgjdbc@github.com>
Subject: Re: [pgjdbc/pgjdbc] PR #3964: feat: add tcpKeepAliveCount, tcpKeepAliveIdle and tcpKeepAliveInterval connection properties
Date: Wed, 09 Sep 2026 20:20:22 +0000
Message-ID: <gh-pgjdbc-pgjdbc-3964-rc3972654676@github.com> (raw)
In-Reply-To: <gh-pgjdbc-pgjdbc-3964@github.com>
References: <gh-pgjdbc-pgjdbc-3964@github.com>

(on pgjdbc/src/main/java11/org/postgresql/core/ExtendedSocketOptionAccessorImpl.java)

**Blocker.** This is the root of most of the review. `socketOption != null` means "the JDK declares the field", and the JDK declares all three unconditionally — it gates only their registration in `supportedOptions()`:

```java
// jdk/src/jdk.net/share/classes/jdk/net/ExtendedSocketOptions.java
public static final SocketOption<Integer> TCP_KEEPCOUNT = new ExtSocketOption<>("TCP_KEEPCOUNT", Integer.class);
...
if (keepAliveOptSupported) {
    options.addAll(Set.of(TCP_KEEPCOUNT, TCP_KEEPIDLE, TCP_KEEPINTERVAL));
}
```

`Socket.setOption`/`getOption` throw `UnsupportedOperationException` for anything outside `supportedOptions()`. Demonstrated with `TCP_QUICKACK`, whose field resolves on macOS while the option is unsupported there:

```
field resolved reflectively: TCP_QUICKACK
supportedOptions contains TCP_QUICKACK = false
get THREW java.lang.UnsupportedOperationException: 'TCP_QUICKACK' not supported
set THREW java.lang.UnsupportedOperationException: 'TCP_QUICKACK' not supported
```

Two real populations land exactly here: Windows on JDK 11-21 (keep-alive options arrived on Windows only in JDK 22 — `jdk-21+35:src/jdk.net/windows/classes/jdk/net/WindowsSocketOptions.java` implements `IP_DONTFRAGMENT` only; `keepAliveOptionsSupported0()` came with `f3ade388dac`, "8308593", first in `jdk-22+8`), and any `socketFactory` whose `Socket` has a custom `SocketImpl` (junixsocket and friends), where the default `supportedOptions()` is empty on every platform:

```
supportedOptions=[]
get TCP_KEEPCOUNT THREW java.lang.UnsupportedOperationException: 'TCP_KEEPCOUNT' not supported
```

The test has to be `socket.supportedOptions().contains(socketOption)`, which means the predicate needs the socket — `isTcpKeepCountSupported(Socket)`.

view thread (85+ messages)  latest in thread

Message-ID: <gh-pgjdbc-pgjdbc-3964-rc3972654676@github.com>
Permalink:  ../gh-pgjdbc-pgjdbc-3964-rc3972654676@github.com/

 · 


This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox