Repository navigation
GH-1526: [JDBC] Allow disabling connections to server-advertised endpoint locations - #1527
Merged
jbonofre merged 5 commits intoNov 27, 2026
Merged
Conversation
added 5 commits
November 26, 2026 11:53
…d endpoint locations Add a followEndpointLocations connection property, defaulting to true so existing behavior is unchanged. When false, getStreams never opens a new connection for an endpoint, so the connection's credentials are only sent to the host the application connected to. Endpoints with no locations, the arrow-flight-reuse-connection location, or a location on the connection's own host (or hostnameOverride, when TLS is enabled) and port are fetched over the existing connection. Other locations are refused through the existing per-location error path, so an endpoint's remaining locations are still tried, and the query fails with an SQLException if none can be used. Closes apache#1526.
An override that includes a port (flight.example.com:32010) never matched, though the docs allow one; it now matches locations on that host and port. Share the host and port check with getHostnameOverrideForEndpoint. Note in the docs that the scheme is ignored, that followed connections also get the client certificate and headers, and that retainCookies and retainAuth have no effect when false. Replace the fallback end-to-end test, which passed with the flag ignored, with one where the server advertises its own location, and cover bracketed IPv6 hosts.
Move the end-to-end tests into ConnectionFollowEndpointLocationsTest, whose servers record the calls they receive. With credentials set, the other server is sent the connection's bearer token by default and receives no calls at all when followEndpointLocations is false. For a server that advertises its own location, the calls come from one client connection instead of two. Also check that a builder copy keeps the setting, and document that hosts are compared without DNS resolution.
Move "whatever its scheme" to the location it applies to, and make the test producer's location volatile, since it is set after the server starts and read on server threads.
Snapshot followEndpointLocations when the handler is built, so changing the builder afterwards can't re-enable following. Only fetch gRPC locations over the existing connection, and grpc+tls ones only over an encrypted connection, since other schemes need another transport, such as an HTTP GET for https. Show only the scheme, host and port of a refused location, since its other parts can hold credentials, such as a presigned URL's signature.
fredjoonpark
requested review from
jbonofre,
laurentgo,
lidavidm and
wgtmac
as code owners
November 26, 2026 21:52
This comment has been minimized.
This comment has been minimized.
jbonofre
approved these changes
Nov 27, 2026
jbonofre
left a comment
Member
There was a problem hiding this comment.
Thanks for this, LGTM.
With followEndpointLocations=false I wouldn't find a way for the server the make the driver open a connection to another host, and the default behaviour is unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's Changed
Adds a
followEndpointLocationsconnection property, defaulting totrueso nothing changes for existing users. Withfalse,getStreamsnever opens a new connection for an endpoint, so the connection's credentials, client certificate and headers only go to the host the application connected to.arrow-flight-reuse-connection://?location, or agrpc,grpc+tcporgrpc+tlslocation on the connection's host and port. Agrpc+tlslocation is only used when the connection uses TLS, and other schemes need another transport, such as an HTTP GET forhttps. Agrpcorgrpc+tcplocation on a TLS connection is fetched over TLS. When TLS is enabled, a location onhostnameOverridealso counts, on the connection's port unless the override includes one. Hosts are compared by name (case-insensitively, IPv6 brackets ignored), without DNS resolution.SQLExceptiononly if an endpoint has no location that can be used. The issue proposes failing on the first such location instead, butFlight.protosays an endpoint's locations are equivalent, so using an allowed one loses nothing.DatabaseMetaData) goes throughgetStreams, so the check is only needed there. The host and port check is shared withgetHostnameOverrideForEndpoint.docs/source/flight_sql_jdbc_driver.rst.Example:
Notes:
true, since changing it would break servers that serve partitions from other hosts.false.false. By default they still get a new connection, as before (see the GH-38574 comment ingetStreams).false. An allowlist could be added later if anyone needs it.Tests
ConnectionFollowEndpointLocationsTest(new). Its servers record the calls they receive:followEndpointLocations=false, the query fails and that server receives no calls;false, and from two by default.ArrowFlightSqlClientHandlerTest: locations on another host (over encrypted and plaintext connections), on another port of the connection's host, and on the connection's host and port but needing another transport (grpc+tlson a plaintext connection,https) are refused without using the client. The connection's own location (includinggrpcandgrpc+tcplocations on an encrypted connection), a location onhostnameOverride, and[other host, arrow-flight-reuse-connection]are fetched over the existing client. The setting is kept after the builder changes, and the refusal message leaves out the location's user info, path, query and fragment.ArrowFlightSqlClientHandlerBuilderTest: location matching for case, a different or missing port, Unix sockets, IPv6 hosts with and without brackets, an override with and without a port, and an override without TLS. Also the default, and that a builder copy keeps the setting.ArrowFlightConnectionConfigImplTest: the default and parsing.This change is additive and has no breaking changes.
The code, tests and docs were drafted with an AI assistant (Claude). The refusal and connection-reuse tests fail when
getStreamsignores the property, and the fullflight-sql-jdbc-corebuild passes.Closes #1526.