1
votes

I am using Netty 4.0.0.Beta2

I have a pipeline which is configured with several handlers, the last of which runs in its own EventExecutorGroup. A little like so:

DefaultEventExecutorGroup separateGroup = new DefaultEventExecutorGroup();

ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(AGGREGATE, new SomeHandler());
pipeline.addLast(ENCODE, new OtherHandler());
pipeline.addLast(extractEventGroup, EXECUTE, new ExecuteHandler());

I then configure a ServerBootstrap with this pipeline configuration as a part of the ChannelInitalizer.

As the server runs, I keep a track of all current clients in a ChannelGroup called 'channels'

Later, when I shut the server down, I flush and close all the channels, then call

bootstrap.shutdown();

That shuts down the NIO EventExecutorGroup, but not the separate DefaultEventExecutorGroup that I have added to the pipeline for my ChannelHandler - meaning the JVM doesn't exit as threads are still active (just waiting, but not released).

I was a little surprised that this wasn't closed as well, so I keep a reference to the DefaultEventExecutorGroup now and manually close that after my bootstrap.shutdown() call:

separateEventGroup.shutdown();

Have I missed something, or is that the expected behaviour of Netty?

2

2 Answers

1
votes

It's actually not a bug but an expected behavior. Think about a JVM that runs multiple protocol servers. Let's say these servers performs disk I/O and you want to limit the number of threads that performs blocking disk I/O across the JVM. You could create a shared EventExecutorGroup for the handlers that perform disk I/O and use it across the multiple protocol servers in the JVM.

-1
votes

I think you are right and this is a bug.. Could you please open a bug-report so we not forget to fix it ?

https://github.com/netty/netty/issues