Fixed issues with StackOverflowErrors when loading Netty on windows.

This commit is contained in:
nathan 2018-04-05 17:13:58 +02:00
parent 03e30ab15c
commit 1d35a9916e

View File

@ -47,6 +47,10 @@ import dorkbox.util.crypto.CryptoECC;
import dorkbox.util.entropy.Entropy;
import dorkbox.util.exceptions.SecurityException;
import io.netty.channel.local.LocalAddress;
import io.netty.handler.codec.ByteToMessageDecoder;
import io.netty.handler.timeout.IdleStateHandler;
import io.netty.resolver.DefaultNameResolver;
import io.netty.resolver.InetSocketAddressResolver;
import io.netty.util.NetUtil;
/**
@ -66,6 +70,26 @@ class EndPoint extends Shutdownable {
// TODO: maybe some sort of STUN-like connection keep-alive??
static {
// have to load some classes early to prevent stack overflow issues on windows
ConnectionImpl.isTcpChannel(null);
ConnectionImpl.isUdpChannel(null);
Object clazz = ByteToMessageDecoder.class;
clazz = IdleStateHandler.class;
try {
// this class is a private, inner class to IdleStateHandler...
clazz = Class.forName("io.netty.handler.timeout.IdleStateHandler$AbstractIdleTask");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
clazz = DefaultNameResolver.class;
clazz = InetSocketAddressResolver.class;
}
public static
String getHostDetails(final SocketAddress socketAddress) {
StringBuilder builder = new StringBuilder();