fredjoonpark opened a new pull request, #1527:
URL: https://github.com/apache/arrow-java/pull/1527
## What's Changed
Adds a `followEndpointLocations` connection property, defaulting to `true`
so nothing changes for existing users. With `false`, `getStreams` never 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.
- An endpoint is fetched over the existing connection if it has no
locations, the `arrow-flight-reuse-connection://?` location, or a `grpc`,
`grpc+tcp` or `grpc+tls` location on the connection's host and port. A
`grpc+tls` location is only used when the connection uses TLS, and other
schemes need another transport, such as an HTTP GET for `https`. A `grpc` or
`grpc+tcp` location on a TLS connection is fetched over TLS. When TLS is
enabled, a location on `hostnameOverride` also counts, on the connection's port
unless the override includes one. Hosts are compared by name
(case-insensitively, IPv6 brackets ignored), without DNS resolution.
- Other locations are skipped through the per-location path that already
refuses non-TLS locations on encrypted connections, so an endpoint's other
locations are still tried. The query fails with an `SQLException` only if an
endpoint has no location that can be used. The issue proposes failing on the
first such location instead, but `Flight.proto` says an endpoint's locations
are equivalent, so using an allowed one loses nothing.
- The message for a skipped location only shows its scheme, host and port,
since its other parts can hold credentials, such as a presigned URL's signature.
- The handler keeps the setting it was built with, so changing the builder
afterwards can't re-enable following.
- Every result fetch (statements, prepared statements and
`DatabaseMetaData`) goes through `getStreams`, so the check is only needed
there. The host and port check is shared with `getHostnameOverrideForEndpoint`.
- Documented in `docs/source/flight_sql_jdbc_driver.rst`.
Example:
```
jdbc:arrow-flight-sql://flight.example.com:443?followEndpointLocations=false
```
Notes:
- The default stays `true`, since changing it would break servers that serve
partitions from other hosts.
- Drivers without this change ignore the property and send it to the server
as a gRPC header, so applications that rely on it need a driver version that
includes it. As for the other boolean properties, a blank or unrecognized value
counts as `false`.
- Locations on the connection's own host and port only reuse the connection
when the property is `false`. By default they still get a new connection, as
before (see the GH-38574 comment in `getStreams`).
- There is no way to allow specific other hosts when the property is
`false`. An allowlist could be added later if anyone needs it.
- The existing message for non-TLS locations on encrypted connections still
shows the whole location URI. That predates this change and could be redacted
the same way separately.
## Tests
- `ConnectionFollowEndpointLocationsTest` (new). Its servers record the
calls they receive:
- by default, a server at another location is sent the connection's bearer
token;
- with `followEndpointLocations=false`, the query fails and that server
receives no calls;
- for a server that advertises its own location, the calls come from one
client connection with `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+tls`
on a plaintext connection, `https`) are refused without using the client. The
connection's own location (including `grpc` and `grpc+tcp` locations on an
encrypted connection), a location on `hostnameOverride`, 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 `getStreams` ignores the property,
and the full `flight-sql-jdbc-core` build passes.
Closes #1526.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]