From 4f391f5bbc6a80ee48cec046aae0b1ec86e5ed0a Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Sun, 15 Feb 2009 12:47:12 +0000 Subject: [PATCH] ReplayingDecoder should not throw an IllegalStateException even if a decoder implementation returns null when state transition occurred at least. --- .../jboss/netty/handler/codec/replay/ReplayingDecoder.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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; }