Skip to content

Enable JEP 380 UDS support for sync client #662

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 1, 2025

Conversation

rschmitt
Copy link
Contributor

This change enables the sync client to use standard library Unix-domain sockets on Java 16+ without a JUnixSocket dependency, as is already supported by the async client.

JEP 380 only exposes Unix-domain socket support through the SocketChannel API, but the sync client is tightly coupled to the legacy java.net.Socket API. The idea behind this change is to wrap the UDS SocketChannel in a subclass of java.net.Socket that acts as a translation layer between the legacy socket API and SocketChannel. In particular, the adapter adds support for socket timeouts by translating blocking reads to non-blocking reads and supplying the socket timeout value to the select() call.

After this change, HttpClient will use the Java standard library by default. JUnixSocket will only be loaded on older versions of Java that lack standard library support for UDS, and even then only for the synchronous client, as the JUnixSocket-provided SocketChannel cannot be used with the JDK-provided Selector used by IOReactor.

This change enables the sync client to use standard library Unix-domain
sockets on Java 16+ without a JUnixSocket dependency, as is already
supported by the async client.

JEP 380 only exposes Unix-domain socket support through the
`SocketChannel` API, but the sync client is tightly coupled to the
legacy `java.net.Socket` API. The idea behind this change is to wrap the
UDS `SocketChannel` in a subclass of `java.net.Socket` that acts as a
translation layer between the legacy socket API and `SocketChannel`. In
particular, the adapter adds support for socket timeouts by translating
blocking reads to non-blocking reads and supplying the socket timeout
value to the `select()` call.

After this change, HttpClient will use the Java standard library by
default. JUnixSocket will only be loaded on older versions of Java that
lack standard library support for UDS, and even then only for the
synchronous client, as the JUnixSocket-provided `SocketChannel` cannot
be used with the JDK-provided `Selector` used by `IOReactor`.
@rschmitt rschmitt merged commit 97703d9 into apache:master Jul 1, 2025
10 checks passed
@rschmitt rschmitt deleted the sync-jep380 branch July 1, 2025 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants