This is an automated email from the ASF dual-hosted git repository.
lidavidm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-adbc.git
The following commit(s) were added to refs/heads/main by this push:
new 8896f6c1e fix(java/driver/flight-sql): cache closes primary connection
on cache invalidate (#4509)
8896f6c1e is described below
commit 8896f6c1ebe803844a288419552f2e5a0c27afed
Author: Daniel_McBride <[email protected]>
AuthorDate: Mon Jul 13 18:11:29 2026 -0700
fix(java/driver/flight-sql): cache closes primary connection on cache
invalidate (#4509)
Closes #4508.
Avoid closing primary connection when it gets invalidated from the
cache.
Co-authored-by: dmcbride <[email protected]>
---
.../apache/arrow/adbc/driver/flightsql/FlightSqlConnection.java | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git
a/java/driver/flight-sql/src/main/java/org/apache/arrow/adbc/driver/flightsql/FlightSqlConnection.java
b/java/driver/flight-sql/src/main/java/org/apache/arrow/adbc/driver/flightsql/FlightSqlConnection.java
index 9f36c9024..123b9828b 100644
---
a/java/driver/flight-sql/src/main/java/org/apache/arrow/adbc/driver/flightsql/FlightSqlConnection.java
+++
b/java/driver/flight-sql/src/main/java/org/apache/arrow/adbc/driver/flightsql/FlightSqlConnection.java
@@ -87,6 +87,8 @@ public class FlightSqlConnection implements AdbcConnection {
this.callOptions = new CallOption[0];
FlightSqlClient flightSqlClient = new
FlightSqlClient(createInitialConnection(location));
this.client = new FlightSqlClientWithCallOptions(flightSqlClient,
callOptions);
+ final Location primaryLocation = location;
+ final FlightSqlClientWithCallOptions primaryClient = this.client;
this.clientCache =
Caffeine.newBuilder()
.expireAfterAccess(5, TimeUnit.MINUTES)
@@ -94,7 +96,7 @@ public class FlightSqlConnection implements AdbcConnection {
(@Nullable Location key,
@Nullable FlightSqlClientWithCallOptions value,
RemovalCause cause) -> {
- if (value == null) return;
+ if (value == null || value == primaryClient) return;
try {
value.close();
} catch (Exception ex) {
@@ -106,6 +108,9 @@ public class FlightSqlConnection implements AdbcConnection {
})
.build(
loc -> {
+ if (loc.equals(primaryLocation)) {
+ return primaryClient;
+ }
FlightClient client = buildClient(loc);
client.handshake(callOptions);
return new FlightSqlClientWithCallOptions(