gpt4 book ai didi

java - 当我在 ChannelHandlerContext 上调用 close() 时,channelInactive() 没有被调用

转载 作者:行者123 更新时间:2023-12-02 12:47:31 27 4
gpt4 key购买 nike

我们一直在使用netty-handler 4.0.28.Final。我们有一个测试,将无效的 xml 写入测试 channel 。如下所示,将调用 ctx.close() 并触发 ChannelInactive。

@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();
}

我的任务是将 netty 更新到 netty-all 4.1.11.Final。自更新以来,channelInactive 没有被调用。 (仅当我们在整理期间在 EmbeddedChannel 上调用 finish() 时才会被调用)。

为什么当我们调用 ctx.close() 时,channelInactive 不再被调用?

最佳答案

这是一个错误,将在下一版本中修复。

参见https://github.com/netty/netty/pull/6897

关于java - 当我在 ChannelHandlerContext 上调用 close() 时,channelInactive() 没有被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44701864/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com