Only set lastReadTime if an read actually happened before in IdleStateHandler.

Motivation:

IdleStateHandler and ReadTimeoutHandler could mistakely not fire an event even if no channelRead(...) call happened.

Modifications:

Only set lastReadTime if a read happened before.

Result:

More correct IdleStateHandler / ReadTimeoutHandler.
This commit is contained in:
Norman Maurer 2016-09-11 10:33:43 +02:00
parent f375772ff0
commit 4a18a143d2

View File

@ -268,7 +268,7 @@ public class IdleStateHandler extends ChannelDuplexHandler {
@Override
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
if (readerIdleTimeNanos > 0 || allIdleTimeNanos > 0) {
if ((readerIdleTimeNanos > 0 || allIdleTimeNanos > 0) && reading) {
lastReadTime = System.nanoTime();
reading = false;
}