diff --git a/transport/src/main/java/io/netty/bootstrap/ServerBootstrap.java b/transport/src/main/java/io/netty/bootstrap/ServerBootstrap.java index 9b42679d27..f9042af46c 100644 --- a/transport/src/main/java/io/netty/bootstrap/ServerBootstrap.java +++ b/transport/src/main/java/io/netty/bootstrap/ServerBootstrap.java @@ -168,7 +168,7 @@ public class ServerBootstrap extends AbstractBootstrap() { @Override - public void initChannel(Channel ch) throws Exception { + public void initChannel(final Channel ch) throws Exception { final ChannelPipeline pipeline = ch.pipeline(); ChannelHandler handler = config.handler(); if (handler != null) { @@ -183,7 +183,7 @@ public class ServerBootstrap extends AbstractBootstrap, Object>[] childOptions; private final Entry, Object>[] childAttrs; + private final Runnable enableAutoReadTask; ServerBootstrapAcceptor( - EventLoopGroup childGroup, ChannelHandler childHandler, + final Channel channel, EventLoopGroup childGroup, ChannelHandler childHandler, Entry, Object>[] childOptions, Entry, Object>[] childAttrs) { this.childGroup = childGroup; this.childHandler = childHandler; this.childOptions = childOptions; this.childAttrs = childAttrs; + + // Task which is scheduled to re-enable auto-read. + // It's important to create this Runnable before we try to submit it as otherwise the URLClassLoader may + // not be able to load the class because of the file limit it already reached. + // + // See https://github.com/netty/netty/issues/1328 + enableAutoReadTask = new Runnable() { + @Override + public void run() { + channel.config().setAutoRead(true); + } + }; } @Override @@ -268,12 +281,7 @@ public class ServerBootstrap extends AbstractBootstrap