Skip to content

DnsNameResolver: allow users to skip bind() during bootstrap#14375

Merged
normanmaurer merged 1 commit intonetty:4.1from
idelpivnitskiy:dns-bind
Sep 26, 2024
Merged

DnsNameResolver: allow users to skip bind() during bootstrap#14375
normanmaurer merged 1 commit intonetty:4.1from
idelpivnitskiy:dns-bind

Conversation

@idelpivnitskiy
Copy link
Copy Markdown
Member

@idelpivnitskiy idelpivnitskiy commented Sep 26, 2024

Motivation:

We prefer to bind by default for better debug logging (see #13817). However, some users expressed concerns with this behavior change because it eagerly binds a UDP port even when allocated resolver is not used.

Modifications:

  • Keep default behavior to bind, but allow configuring null for DnsNameResolverBuilder.localAddress(...) to preserve pre-existing behavior.

Result:

Users can force pre-existing behavior of lazy port binding on resolve.

Motivation:

We prefer to bind by default for better debug logging (see netty#13817).
However, some users expressed concerns with this behavior change
because it eagerly binds a UDP port even when allocated resolver
is not used.

Modifications:

- Keep default behavior to bind, but allow configuring `null` for
`DnsNameResolverBuilder.localAddress(...)` to preserve pre-existing
behavior.

Result:

Users can opt-in for pre-existing behavior of lazy port binding on
resolve.
@normanmaurer normanmaurer added this to the 4.1.114.Final milestone Sep 26, 2024
@normanmaurer normanmaurer merged commit c036b99 into netty:4.1 Sep 26, 2024
normanmaurer pushed a commit that referenced this pull request Sep 26, 2024
Motivation:

We prefer to bind by default for better debug logging (see #13817).
However, some users expressed concerns with this behavior change because
it eagerly binds a UDP port even when allocated resolver is not used.

Modifications:

- Keep default behavior to bind, but allow configuring `null` for
`DnsNameResolverBuilder.localAddress(...)` to preserve pre-existing
behavior.

Result:

Users can force pre-existing behavior of lazy port binding on resolve.
@chrisvest
Copy link
Copy Markdown
Member

The Netty/Testsuite/NativeImage/Client module now fails to build, with the following error:

2024-09-26T19:15:37.4835878Z Error: No instances of java.net.Inet4Address are allowed in the image heap as this class should be initialized at image runtime. To see how this object got instantiated use --trace-object-instantiation=java.net.Inet4Address.
2024-09-26T19:15:37.4839393Z Detailed message:
2024-09-26T19:15:37.4839878Z Trace: Object was reached by 
2024-09-26T19:15:37.4840743Z 	reading field java.net.InetSocketAddress$InetSocketAddressHolder.addr of
2024-09-26T19:15:37.4842378Z 		constant java.net.InetSocketAddress$InetSocketAddressHolder@60a1b097 reached by 
2024-09-26T19:15:37.4843400Z 	reading field java.net.InetSocketAddress.holder of
2024-09-26T19:15:37.4844246Z 		constant java.net.InetSocketAddress@6a11e961 reached by 
2024-09-26T19:15:37.4845518Z 	scanning method io.netty.resolver.dns.DnsNameResolverBuilder.<init>(DnsNameResolverBuilder.java:57)
2024-09-26T19:15:37.4847184Z Call path from entry point to io.netty.resolver.dns.DnsNameResolverBuilder.<init>(): 
2024-09-26T19:15:37.4848586Z 	at io.netty.resolver.dns.DnsNameResolverBuilder.<init>(DnsNameResolverBuilder.java:84)
2024-09-26T19:15:37.4850027Z 	at io.netty.resolver.dns.DnsAddressResolverGroup.<init>(DnsAddressResolverGroup.java:54)
2024-09-26T19:15:37.4851404Z 	at io.netty.testsuite.svm.client.DnsNativeClient.main(DnsNativeClient.java:41)
2024-09-26T19:15:37.4852866Z 	at com.oracle.svm.core.JavaMainWrapper.runCore(JavaMainWrapper.java:146)
2024-09-26T19:15:37.4854056Z 	at com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:182)
2024-09-26T19:15:37.4855226Z 	at com.oracle.svm.core.code.IsolateEnterStub.JavaMainWrapper_run_5087f5482cc9a6abc971913ece43acb471d2631b(generated:0)
2024-09-26T19:15:37.4855841Z 
2024-09-26T19:15:37.4856276Z Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
2024-09-26T19:15:37.5271344Z Error: Image build request failed with exit status 1

Please take a look, @idelpivnitskiy.

normanmaurer pushed a commit that referenced this pull request Sep 27, 2024
Motivation:

We prefer to bind by default for better debug logging (see #13817).
However, some users expressed concerns with this behavior change because
it eagerly binds a UDP port even when allocated resolver is not used.

Modifications:

- Keep default behavior to bind, but allow configuring `null` for
`DnsNameResolverBuilder.localAddress(...)` to preserve pre-existing
behavior.

Result:

Users can force pre-existing behavior of lazy port binding on resolve.
@idelpivnitskiy idelpivnitskiy deleted the dns-bind branch September 27, 2024 10:40
@idelpivnitskiy
Copy link
Copy Markdown
Member Author

@chrisvest This is because I initialize a default localhost address in a static variable.
Can you help me to understand why this is a problem and what is triggering this error? I certainly can refactor, just don't understand why it's necessary.

@idelpivnitskiy
Copy link
Copy Markdown
Member Author

nvm, I googled and found that this is bcz of the native images

idelpivnitskiy added a commit to idelpivnitskiy/netty that referenced this pull request Sep 27, 2024
Motivation:

After netty#14375 Netty/Testsuite/NativeImage/Client started to fail with:
No instances of `java.net.Inet4Address` are allowed in the image heap
as this class should be initialized at image runtime.

Modifications:

- Add `DnsNameResolverBuilder` to `native-image.properties`;

Result:

Netty/Testsuite/NativeImage/Client is expected to start working again.
chrisvest pushed a commit that referenced this pull request Sep 27, 2024
)

Motivation:

After #14375 Netty/Testsuite/NativeImage/Client started to fail with: No
instances of `java.net.Inet4Address` are allowed in the image heap as
this class should be initialized at image runtime.

Modifications:

- Add `DnsNameResolverBuilder` to `native-image.properties`;

Result:

Netty/Testsuite/NativeImage/Client is expected to start working again.
chrisvest pushed a commit that referenced this pull request Sep 27, 2024
)

Motivation:

After #14375 Netty/Testsuite/NativeImage/Client started to fail with: No
instances of `java.net.Inet4Address` are allowed in the image heap as
this class should be initialized at image runtime.

Modifications:

- Add `DnsNameResolverBuilder` to `native-image.properties`;

Result:

Netty/Testsuite/NativeImage/Client is expected to start working again.
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