Paulie22
Paulie22

Reputation: 111

channelInactive() not getting called when I call close() on the ChannelHandlerContext

We have been using netty-handler 4.0.28.Final. We have a test where we write invalid xml to a test channel. As below ctx.close() would be called and channelInactive would fire.

@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable exc) {
    if (connectionListener == null) {
        return;
    }

    // Treat unexpected exceptions as fatal to the connection
    try {
        connectionListener.connectionError(exc);
    } finally {
        ctx.close();
    }
}

@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
    if (connectionListener == null) {
        return;
    }
    connectionListener.connectionClosed();
}

I have been tasked with updating netty to netty-all 4.1.11.Final. Since updating, channelInactive is not getting called. (Only gets called when when we call finish() on the EmbeddedChannel during tidy up).

Why would channelInactive no longer be called when we call ctx.close()?

Upvotes: 0

Views: 1271

Answers (1)

Norman Maurer
Norman Maurer

Reputation: 23557

This is a bug and will be fixed in the next release.

see https://github.com/netty/netty/pull/6897

Upvotes: 1

Related Questions