Skip to content

Add native JDK support for UDS on Java 16+#262

Open
sarahchen6 wants to merge 32 commits into
masterfrom
sarahchen6/add-jdk-uds-support-pt2
Open

Add native JDK support for UDS on Java 16+#262
sarahchen6 wants to merge 32 commits into
masterfrom
sarahchen6/add-jdk-uds-support-pt2

Conversation

@sarahchen6

@sarahchen6 sarahchen6 commented Mar 25, 2025

Copy link
Copy Markdown

This PR introduces native JDK support for UDS, which was added in Java 16: https://openjdk.org/jeps/380. This is done by:

  • Adding a new configuration option enableJdkSocket to enable native JDK support for UDS for compatible versions (Java 16+)
  • Updating primarily NonBlockingStatsDClient, NonBlockingStatsDClientBuilder, and UnixStreamClientChannel. UnixDatagramClientChannel cannot be updated at this time.
  • Adding a VersionUtils file that parses Java versions.

This PR follows DataDog/dd-trace-java#8314, which added native JDK support to dd-trace-java. With native support, we can reduce third party (i.e. jnr-unixsocket) dependencies.

@sarahchen6
sarahchen6 force-pushed the sarahchen6/add-jdk-uds-support-pt2 branch from e356aaf to 675dddf Compare August 22, 2025 20:27
@sarahchen6
sarahchen6 force-pushed the sarahchen6/add-jdk-uds-support-pt2 branch 2 times, most recently from 34af4da to c888794 Compare August 24, 2025 02:06
@sarahchen6
sarahchen6 force-pushed the sarahchen6/add-jdk-uds-support-pt2 branch from c888794 to 619e4d9 Compare August 24, 2025 02:14
@sarahchen6
sarahchen6 marked this pull request as ready for review September 8, 2025 17:10
@sarahchen6
sarahchen6 requested a review from a team as a code owner September 8, 2025 17:10
@datadog-prod-us1-4

This comment has been minimized.

@bric3

bric3 commented Jul 7, 2026

Copy link
Copy Markdown

@carlosroman Any update on this ?

@carlosroman
carlosroman requested a review from Copilot July 16, 2026 16:37
@carlosroman

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f7f9688016

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/main/java/com/timgroup/statsd/NonBlockingStatsDClientBuilder.java Outdated
Comment thread src/main/java/com/timgroup/statsd/UnixStreamClientChannel.java Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add a test around this class?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! Added in 3815fe6

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds an optional native-JDK (Java 16+) Unix Domain Socket (UDS) implementation path, reducing reliance on jnr-unixsocket when running on modern JDKs while keeping compatibility with older versions.

Changes:

  • Adds enableJdkSocket configuration and plumbing through the builder/client to enable native JDK UDS support on Java 16+.
  • Introduces VersionUtils for Java version parsing plus reflective access to StandardProtocolFamily.UNIX and UnixDomainSocketAddress.
  • Updates UnixStreamClientChannel to use native SocketChannel for UDS stream connections when enabled; adjusts tests accordingly.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/main/java/com/timgroup/statsd/NonBlockingStatsDClient.java Passes enableJdkSocket into channel creation.
src/main/java/com/timgroup/statsd/NonBlockingStatsDClientBuilder.java Adds enableJdkSocket option and uses it during unix URL resolution.
src/main/java/com/timgroup/statsd/UnixStreamClientChannel.java Implements native-JDK UDS stream connect/write behavior behind a Java 16+ + flag gate.
src/main/java/com/timgroup/statsd/UnixDatagramClientChannel.java Documents why native JDK UDS datagram isn’t available yet.
src/main/java/com/timgroup/statsd/VersionUtils.java Adds Java version parsing and reflection helpers for Java 16+ UDS APIs.
src/test/java/com/timgroup/statsd/BuilderAddressTest.java Adjusts address assertions to tolerate native-JDK address types.
src/test/java/com/timgroup/statsd/NonBlockingStatsDClientTest.java Updates overridden createByteChannel signatures for the new parameter.
src/test/java/com/timgroup/statsd/UnixStreamSocketDummyStatsDServer.java Minor refactor in unix socket bind setup.
src/test/java/com/timgroup/statsd/UnixStreamSocketTest.java Tweaks UDS stream test behavior/assertions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/main/java/com/timgroup/statsd/VersionUtils.java
Comment thread src/main/java/com/timgroup/statsd/UnixStreamClientChannel.java Outdated
Comment thread src/main/java/com/timgroup/statsd/UnixDatagramClientChannel.java
@sarahchen6

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3815fe69db

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/main/java/com/timgroup/statsd/UnixStreamClientChannel.java Outdated
Comment thread src/main/java/com/timgroup/statsd/UnixStreamClientChannel.java Outdated
@sarahchen6

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e71516eedc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/main/java/com/timgroup/statsd/UnixStreamClientChannel.java Outdated
Comment thread src/main/java/com/timgroup/statsd/UnixStreamClientChannel.java
@sarahchen6
sarahchen6 marked this pull request as draft July 17, 2026 16:15
@sarahchen6

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f5c09ed16a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/main/java/com/timgroup/statsd/UnixStreamClientChannel.java
@sarahchen6
sarahchen6 marked this pull request as ready for review July 17, 2026 18:09
@sarahchen6
sarahchen6 requested a review from carlosroman July 17, 2026 18:09

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a2c667061a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/main/java/com/timgroup/statsd/UnixStreamClientChannel.java
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.

4 participants