Do not try to retrieve domain search list via reflection hack on windows when using Java9 and later (#9511)
Motivation: We currently try to access the the domain search list via reflection on windows which will print a illegal access warning when using Java9 and later. Modifications: Add a guard against the used java version. Result: Fixes https://github.com/netty/netty/issues/9500.
This commit is contained in:
parent
a89cde9475
commit
68673b652e
@ -177,6 +177,9 @@ public class DnsNameResolver extends InetNameResolver {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static List<String> getSearchDomainsHack() throws Exception {
|
||||
// Only try if not using Java9 and later
|
||||
// See https://github.com/netty/netty/issues/9500
|
||||
if (PlatformDependent.javaVersion() < 9) {
|
||||
// This code on Java 9+ yields a warning about illegal reflective access that will be denied in
|
||||
// a future release. There doesn't seem to be a better way to get search domains for Windows yet.
|
||||
Class<?> configClass = Class.forName("sun.net.dns.ResolverConfiguration");
|
||||
@ -186,6 +189,8 @@ public class DnsNameResolver extends InetNameResolver {
|
||||
|
||||
return (List<String>) nameservers.invoke(instance);
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
private static final DatagramDnsResponseDecoder DATAGRAM_DECODER = new DatagramDnsResponseDecoder() {
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user