IdleStateHandler.initialize() and ReadTimeoutHandler.initialize() must not be called if their pipeline is not attached yet. Otherwise the timeout might occur even before the connection is established.
This commit is contained in:
parent
2bf4dfcfb9
commit
3fcfc910e1
@ -201,7 +201,10 @@ public class IdleStateHandler extends SimpleChannelUpstreamHandler
|
||||
}
|
||||
|
||||
public void beforeAdd(ChannelHandlerContext ctx) throws Exception {
|
||||
initialize(ctx);
|
||||
if (ctx.getPipeline().isAttached()) {
|
||||
// channelOpen() has been called already - initialize here instead.
|
||||
initialize(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
public void afterAdd(ChannelHandlerContext ctx) throws Exception {
|
||||
@ -219,7 +222,7 @@ public class IdleStateHandler extends SimpleChannelUpstreamHandler
|
||||
@Override
|
||||
public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e)
|
||||
throws Exception {
|
||||
lastReadTime = lastWriteTime = System.currentTimeMillis();
|
||||
initialize(ctx);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -120,7 +120,10 @@ public class ReadTimeoutHandler extends SimpleChannelUpstreamHandler
|
||||
}
|
||||
|
||||
public void beforeAdd(ChannelHandlerContext ctx) throws Exception {
|
||||
initialize(ctx);
|
||||
if (ctx.getPipeline().isAttached()) {
|
||||
// channelOpen() has been called already - initialize here instead.
|
||||
initialize(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
public void afterAdd(ChannelHandlerContext ctx) throws Exception {
|
||||
@ -138,7 +141,7 @@ public class ReadTimeoutHandler extends SimpleChannelUpstreamHandler
|
||||
@Override
|
||||
public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e)
|
||||
throws Exception {
|
||||
updateLastReadTime();
|
||||
initialize(ctx);
|
||||
ctx.sendUpstream(e);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user