ff-wl commented on a change in pull request #886:
URL: https://github.com/apache/james-project/pull/886#discussion_r808754396
##########
File path:
protocols/netty/src/main/java/org/apache/james/protocols/netty/AbstractAsyncServer.java
##########
@@ -85,54 +94,67 @@ public synchronized void bind() throws Exception {
throw new RuntimeException("Please specify at least on
socketaddress to which the server should get bound!");
}
- bootstrap = new ServerBootstrap(createSocketChannelFactory());
- ChannelPipelineFactory factory = createPipelineFactory(channels);
-
+ bootstrap = new ServerBootstrap();
+ bootstrap.channel(NioServerSocketChannel.class);
+
+ bossGroup = new NioEventLoopGroup();
+ workerGroup = new NioEventLoopGroup();
+
+ bootstrap.group(bossGroup, workerGroup);
+
+ ChannelInitializer<SocketChannel> factory =
createPipelineFactory(channels);
+
// Configure the pipeline factory.
- bootstrap.setPipelineFactory(factory);
- configureBootstrap(bootstrap);
+ bootstrap.childHandler(factory);
for (InetSocketAddress address : addresses) {
- channels.add(bootstrap.bind(address));
+ Channel channel = bootstrap.bind(address).sync().channel();
+ channels.add(channel);
}
- started = true;
+ configureBootstrap(bootstrap);
+
+ started = true;
}
/**
* Configure the bootstrap before it get bound
*/
protected void configureBootstrap(ServerBootstrap bootstrap) {
// Bind and start to accept incoming connections.
- bootstrap.setOption("backlog", backlog);
- bootstrap.setOption("reuseAddress", true);
- bootstrap.setOption("child.tcpNoDelay", true);
- }
-
- protected ServerSocketChannelFactory createSocketChannelFactory() {
- return new NioServerSocketChannelFactory(createBossExecutor(),
createWorkerExecutor(), ioWorker);
+ bootstrap.option(ChannelOption.SO_BACKLOG, backlog);
+ bootstrap.option(ChannelOption.SO_REUSEADDR, true);
+ bootstrap.option(ChannelOption.TCP_NODELAY, true);
}
-
@Override
public synchronized void unbind() {
if (started == false) {
return;
}
- ChannelPipelineFactory factory = bootstrap.getPipelineFactory();
- if (factory instanceof ExternalResourceReleasable) {
- ((ExternalResourceReleasable) factory).releaseExternalResources();
+
+ if (bossGroup != null) {
+ bossGroup.shutdownGracefully();
}
- channels.close().awaitUninterruptibly();
- bootstrap.releaseExternalResources();
+
+ if (workerGroup != null) {
+ workerGroup.shutdownGracefully();
+ }
+
+ // ChannelPipelineFactory factory =
bootstrap.getPipelineFactory();
+ // if (factory instanceof ExternalResourceReleasable) {
+ // ((ExternalResourceReleasable)
factory).releaseExternalResources();
+ // }
+ // channels.close().awaitUninterruptibly();
+ // bootstrap.releaseExternalResources();
Review comment:
fixed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]