diff --git a/transport/src/main/java/io/netty/channel/nio/AbstractNioMessageChannel.java b/transport/src/main/java/io/netty/channel/nio/AbstractNioMessageChannel.java index c674cb5dd0..9a09956663 100644 --- a/transport/src/main/java/io/netty/channel/nio/AbstractNioMessageChannel.java +++ b/transport/src/main/java/io/netty/channel/nio/AbstractNioMessageChannel.java @@ -48,16 +48,19 @@ public abstract class AbstractNioMessageChannel extends AbstractNioChannel { private final List readBuf = new ArrayList(); + private void removeReadOp() { + SelectionKey key = selectionKey(); + int interestOps = key.interestOps(); + if ((interestOps & readInterestOp) != 0) { + // only remove readInterestOp if needed + key.interestOps(interestOps & ~readInterestOp); + } + } @Override public void read() { assert eventLoop().inEventLoop(); - final SelectionKey key = selectionKey(); if (!config().isAutoRead()) { - int interestOps = key.interestOps(); - if ((interestOps & readInterestOp) != 0) { - // only remove readInterestOp if needed - key.interestOps(interestOps & ~readInterestOp); - } + removeReadOp(); } final ChannelConfig config = config();