Adding handlers to a closed Channel's pipeline
See original GitHub issueIt appears the a ChannelPipeline will happily add a handler to a closed Channel’s pipeline and will call handlerAdded(...)
but will not call handlerRemoved(...)
or blow up in some other way to let the caller know that things aren’t in a good state.
Just wondering if there wouldn’t be edge cases where we’d potentially leak resources (e.g. SslHandler#handlerRemoved0(...)
which is supposed to release a reference counted SSLEngine).
Expected behavior
Fail with Exception or handlerRemoved(...)
getting called after handlerAdded(...)
Actual behavior
handlerAdded(...)
getting called as if everything is ok
Steps to reproduce
Minimal yet complete reproducer code (or URL to code)
@Test
public void testHandlerAfterClose() throws Exception {
EmbeddedChannel channel = new EmbeddedChannel();
channel.close().syncUninterruptibly();
assertFalse(channel.isActive());
final CountDownLatch addedLatch = new CountDownLatch(1);
final CountDownLatch removedLatch = new CountDownLatch(1);
ChannelPipeline pipeline = channel.pipeline();
pipeline.addLast(new ChannelHandlerAdapter() {
@Override
public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
addedLatch.countDown();
}
@Override
public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
removedLatch.countDown();
}
});
assertTrue(addedLatch.await(1L, TimeUnit.SECONDS));
assertTrue(removedLatch.await(1L, TimeUnit.SECONDS));
}
Netty version
JVM version (e.g. java -version
)
OS version (e.g. uname -a
)
Issue Analytics
- State:
- Created 6 years ago
- Comments:12 (12 by maintainers)
Top Results From Across the Web
ChannelPipeline (Netty API Reference (4.0.56.Final))
A user is supposed to have one or more ChannelHandler s in a pipeline to receive I/O events (e.g. read) and to request...
Read more >Pipeline handler ordering and other questions - SwiftNIO
I'm currently implementing an MQTT broker using SwiftNIO and I'm having trouble understanding a few things. First and foremost, I can't seem ...
Read more >How to dynamic add/remove handlers outside of a handler
I know netty supported dynamically adding/removing handlers in pipeline, but however I could find almost all the samples said how to implement ...
Read more >Example usage for io.netty.channel Channel pipeline - Java2s.com
Usage ; new DefaultSmppSession(SmppSession.Type.CLIENT, config, channel, sessionHandler, monitorExecutor); // add SSL handler if ; if (sslConfig == null) throw ...
Read more >A Tour of Netty. Introduction | by Kondah Mouad | Geek Culture
Whenever a channel is created, a ChannelPipeline is created and ... step would be to initialise our channel, that is, adding handlers ect…...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Scottmitch I think non static exception is better as I not expect this to be thrown often and it will be better to have some context
Yes I missed to close this 😕