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: Thu, 22 Oct 2026 08:14:13 +0000
Message-ID: <gh-pgjdbc-pgjdbc-3964-rc4346009462@github.com> (raw)
In-Reply-To: <gh-pgjdbc-pgjdbc-3964@github.com>
References: <gh-pgjdbc-pgjdbc-3964@github.com>
(on pgjdbc/src/main/java/org/postgresql/ds/common/BaseDataSource.java)
HikariCP cannot set `Integer` setters from a string when the pool is configured through `dataSourceClassName=org.postgresql.ds.PGSimpleDataSource` (`dataSource.tcpKeepAliveIdle=30`, `addDataSourceProperty("tcpKeepAliveIdle", "30")`, or Spring's `spring.datasource.hikari.data-source-class-name` with `data-source-properties.*`). `PropertyElf.setProperty` converts only `int`, `long`, `short`, `boolean`/`Boolean`, arrays and `String`. For `Integer.class` it falls through to `Class.forName("30")`, then `writeMethod.invoke(target, "30")`, which throws `IllegalArgumentException`, rethrown as `RuntimeException`, and the pool fails to start.
These would be the only `Integer`-typed bean properties in `BaseDataSource`; every other numeric property is `int`. My July comment spelled the setter `setTcpKeepAliveCount(Integer)`; that type is the problem. Please use `int` getters and setters with a value for "unset", the way `sendBufferSize` and `receiveBufferSize` use `-1`, and make the setter remove the key for it. The type is a compatibility promise once released, so it has to be settled before merge.
Please also extend the loop in `PGPropertyTest.dataSourceProperties` that already looks up the getter and setter of every `PGProperty` through `Introspector`: assert that the setter's parameter type is `String`, `int` or `boolean`, the types every pool and binder can convert from a string. That check fails on the current three setters and catches the same mistake in any future property, with no new test dependency.
(Same for `setTcpKeepAliveIdle` at :937 and `setTcpKeepAliveInterval` at :962.)