diff --git a/src/main/java/org/jboss/netty/handler/codec/replay/ReplayingDecoder.java b/src/main/java/org/jboss/netty/handler/codec/replay/ReplayingDecoder.java index dd1e7ec1b3..e3bc417c4a 100644 --- a/src/main/java/org/jboss/netty/handler/codec/replay/ReplayingDecoder.java +++ b/src/main/java/org/jboss/netty/handler/codec/replay/ReplayingDecoder.java @@ -371,11 +371,11 @@ public abstract class ReplayingDecoder> try { result = decode(context, channel, replayable, state); if (result == null) { - if (oldReaderIndex == cumulation.readerIndex()) { + if (oldReaderIndex == cumulation.readerIndex() && oldState == state) { throw new IllegalStateException( - "null cannot be returned if no data is consumed."); + "null cannot be returned if no data is consumed and state didn't change."); } else { - // Previous data has been discarded. + // Previous data has been discarded or caused state transition. // Probably it is reading on. continue; }