Skip to content
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

Hosts with DNS suffixes cannot be resolved in Windows 10 and Java 9+ #12712

Open
flupec opened this issue Aug 18, 2022 · 1 comment · Fixed by #13022 · May be fixed by #13163
Open

Hosts with DNS suffixes cannot be resolved in Windows 10 and Java 9+ #12712

flupec opened this issue Aug 18, 2022 · 1 comment · Fixed by #13022 · May be fixed by #13163

Comments

@flupec
Copy link

flupec commented Aug 18, 2022

I am using Spring WebClient based on netty and it cannot resolve hosts with DNS suffixes on Windows and Java 9+. I think this hack is responsible for such behaviour.

Why is reflection used here? You can acquire instance of ResolverConfiguration via static method, no?

Java 8 works fine though. I think issue is simillar to this.

Expected behavior

Hosts with dns suffixes resolves succesfully

Actual behavior

UnknownHostException

Caused by: java.net.UnknownHostException: failed to resolve 'my-host' after 8 queries 
	at io.netty.resolver.dns.DnsResolveContext.finishResolve(DnsResolveContext.java:1046)
	at io.netty.resolver.dns.DnsResolveContext.tryToFinishResolve(DnsResolveContext.java:999)
	at io.netty.resolver.dns.DnsResolveContext.query(DnsResolveContext.java:417)
	at io.netty.resolver.dns.DnsResolveContext.onResponse(DnsResolveContext.java:628)
	at io.netty.resolver.dns.DnsResolveContext.access$400(DnsResolveContext.java:65)
	at io.netty.resolver.dns.DnsResolveContext$2.operationComplete(DnsResolveContext.java:461)
	at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:578)
	at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:571)
	at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:550)
	at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:491)
	at io.netty.util.concurrent.DefaultPromise.setValue0(DefaultPromise.java:616)
	at io.netty.util.concurrent.DefaultPromise.setSuccess0(DefaultPromise.java:605)
	at io.netty.util.concurrent.DefaultPromise.trySuccess(DefaultPromise.java:104)
	at io.netty.resolver.dns.DnsQueryContext.trySuccess(DnsQueryContext.java:201)
	at io.netty.resolver.dns.DnsQueryContext.finish(DnsQueryContext.java:193)
	at io.netty.resolver.dns.DnsNameResolver$DnsResponseHandler.channelRead(DnsNameResolver.java:1301)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
	at io.netty.channel.nio.AbstractNioMessageChannel$NioMessageUnsafe.read(AbstractNioMessageChannel.java:97)
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:719)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:833)

Steps to reproduce

Configure DNS suffixes on Windows. This can be achieved like this: edit SearchList property at registry path HKLM\SYSTEM\CurrentControlSet\services\Tcpip\Parameters.

Netty version

4.1.77.Final

JVM version (e.g. java -version)

openjdk version "17.0.2" 2022-01-18
OpenJDK Runtime Environment (build 17.0.2+8-86)
OpenJDK 64-Bit Server VM (build 17.0.2+8-86, mixed mode, sharing)

OS version (e.g. uname -a)

Windows 10

@flupec flupec changed the title DNS suffixes cannot be resolved in Windows 10 and Java 9+ Hosts with DNS suffixes cannot be resolved in Windows 10 and Java 9+ Aug 18, 2022
@normanmaurer
Copy link
Member

@flupec the problem is that this is a "private" api that you can only access via reflection which will fail in java9+ or at least produce an error log. So there is not much we can do about it .

normanmaurer added a commit that referenced this issue Jan 27, 2023
Motivation:
On Windows with JDK 9+ the search domain and dns servers are missing.

Modification:

This PR uses JNI to fetch the DNS Servers from the operating system.

Result:

Fixes #12712 #11885. 

Co-authored-by: Norman Maurer <norman_maurer@apple.com>
@normanmaurer normanmaurer added this to the 4.1.88.Final milestone Jan 27, 2023
normanmaurer added a commit that referenced this issue Jan 27, 2023
Motivation:
On Windows with JDK 9+ the search domain and dns servers are missing.

Modification:

This PR uses JNI to fetch the DNS Servers from the operating system.

Result:

Fixes #12712 #11885. 

Co-authored-by: Norman Maurer <norman_maurer@apple.com>
@normanmaurer normanmaurer removed this from the 4.1.88.Final milestone Feb 13, 2023
@normanmaurer normanmaurer reopened this Feb 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants