SUPPORT = support;
}
- private final boolean supportsKeepalives;
+ static final NioNettyImpl INSTANCE;
- NioNettyImpl() {
- final var ch = new NioSocketChannel();
+ static {
+ final var grp = new NioEventLoopGroup();
try {
- supportsKeepalives = SUPPORT.configureKeepalives(ch.config());
- } finally {
- ch.close();
+ try {
+ final var ch = new NioSocketChannel();
+ grp.register(ch).sync();
+
+ final boolean supportsKeepalives;
+ try {
+ supportsKeepalives = SUPPORT.configureKeepalives(ch.config());
+ } finally {
+ ch.close().sync();
+ }
+ INSTANCE = new NioNettyImpl(supportsKeepalives);
+ } finally {
+ grp.shutdownGracefully().sync();
+ }
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new ExceptionInInitializerError(e);
}
}
+ private final boolean supportsKeepalives;
+
+ private NioNettyImpl(final boolean supportsKeepalives) {
+ this.supportsKeepalives = supportsKeepalives;
+ }
+
@Override
Class<NioSocketChannel> channelClass() {
return NioSocketChannel.class;