Call Bootstrap.connect() with resolved InetSocketAddress#137
Merged
kevinherron merged 2 commits intomasterfrom Dec 9, 2025
Merged
Call Bootstrap.connect() with resolved InetSocketAddress#137kevinherron merged 2 commits intomasterfrom
Bootstrap.connect() with resolved InetSocketAddress#137kevinherron merged 2 commits intomasterfrom
Conversation
Co-authored-by: kevinherron <340273+kevinherron@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix unresolved InetSocketAddress issue in Netty transport
Call Dec 9, 2025
Bootstrap.connect() with resolved InetSocketAddress
kevinherron
approved these changes
Dec 9, 2025
There was a problem hiding this comment.
Pull request overview
This PR fixes a performance issue where hostname resolution was occurring on Netty event loop threads instead of the calling thread. This mirrors the fix from eclipse-milo/milo#1668 and ensures DNS resolution doesn't block event loop threads that should be reserved for I/O operations.
Key Changes:
- Modified both Netty client transport implementations to pre-construct
InetSocketAddressobjects before passing them toBootstrap.connect() - Added
java.net.InetSocketAddressimport to both affected files
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| modbus-tcp/src/main/java/com/digitalpetri/modbus/tcp/client/NettyTcpClientTransport.java | Updated TCP client transport to resolve hostnames on the calling thread by pre-constructing InetSocketAddress |
| modbus-tcp/src/main/java/com/digitalpetri/modbus/tcp/client/NettyRtuClientTransport.java | Updated RTU/TCP client transport to resolve hostnames on the calling thread by pre-constructing InetSocketAddress |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Hostname resolution was occurring on Netty event loop threads instead of the calling thread. This mirrors the fix in eclipse-milo/milo#1668.
Changes
InetSocketAddressbefore passing toBootstrap.connect()InetSocketAddressbefore passing toBootstrap.connect()Technical Details
Calling
Bootstrap.connect(hostname, port)creates an unresolvedInetSocketAddressthat Netty resolves later on its event loop. Passing a pre-constructedInetSocketAddress(hostname, port)forces immediate DNS resolution on the calling thread.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
checkstyle.org/opt/hostedtoolcache/CodeQL/2.23.6/x64/codeql/tools/linux64/java/bin/java /opt/hostedtoolcache/CodeQL/2.23.6/x64/codeql/tools/linux64/java/bin/java -jar /opt/hostedtoolcache/CodeQL/2.23.6/x64/codeql/xml/tools/xml-extractor.jar --fileList=/home/REDACTED/work/modbus/.codeql-scratch/dbs/java/working/files-to-index11882398739134291682.list --sourceArchiveDir=/home/REDACTED/work/modbus/.codeql-scratch/dbs/java/src --outputDir=/home/REDACTED/work/modbus/.codeql-scratch/dbs/java/trap/java(dns block)https://api.github.com/repos/eclipse-milo/milo/pulls/1668/usr/bin/curl curl -s REDACTED(http block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.