Bootstrap shutdown should also shutdown pipeline EventExecutorGroups. #1220

Closed
d-t-w opened this Issue Apr 1, 2013 · 2 comments

Comments

Projects
None yet
2 participants
@d-t-w
Contributor

d-t-w commented Apr 1, 2013

Initially: http://stackoverflow.com/questions/15675605/netty-4-eventexecutorgroup-shutdown

Found in 4.0.0.Beta2:

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

extractEventGroup = new DefaultEventExecutorGroup()

channelInitializer = new ChannelInitializer<SocketChannel>() {
    @Override
    public void initChannel(SocketChannel ch) throws Exception {
    ChannelPipeline pipeline = ch.pipeline();
    pipeline.addLast(DECODE, new SomeHandler());
    pipeline.addLast(ENCODE, new AnotherHandler());
    pipeline.addLast(extractEventGroup, EXECUTE, new ExecuteHandler());
    }
};

I create a bootstrap using with this pipeline configured in my ChannelInitializer:

ServerBootstrap bootstrap = new ServerBootstrap();
bootstrap.group(new NioEventLoopGroup())
    .channel(NioServerSocketChannel.class)
    .localAddress(address)
    .childHandler(channelInitializer);

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

bootstrap.shutdown();

That shuts down the NioEventLoopGroup, but not the separate extractEventGroup 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 had expected that closing the bootstrap would also close any EventExecutorGroups associated with it.

@trustin

This comment has been minimized.

Show comment
Hide comment
@trustin

trustin Apr 2, 2013

Member

This is an intentional behavior. Netty should not make an assumption that an EventExecutorGroup a user specified when adding a handler to a pipeline is being used exclusively. Otherwise, a user cannot share the executor group with other bootstraps or EventLoopGroups.

Member

trustin commented Apr 2, 2013

This is an intentional behavior. Netty should not make an assumption that an EventExecutorGroup a user specified when adding a handler to a pipeline is being used exclusively. Otherwise, a user cannot share the executor group with other bootstraps or EventLoopGroups.

@trustin

This comment has been minimized.

Show comment
Hide comment
@trustin

trustin Apr 2, 2013

Member

We are going to fix this problem differently - see #1224

Member

trustin commented Apr 2, 2013

We are going to fix this problem differently - see #1224

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment