ReplayingDecoder should not complain when the state has been changed

This commit is contained in:
Trustin Lee 2008-11-30 16:24:17 +00:00
parent d4348ab4d7
commit 7b69bf371b

View File

@ -318,6 +318,7 @@ public abstract class ReplayingDecoder<T extends Enum<T>> extends SimpleChannelH
while (cumulation.readable()) { while (cumulation.readable()) {
int oldReaderIndex = checkpoint = cumulation.readerIndex(); int oldReaderIndex = checkpoint = cumulation.readerIndex();
Object result = null; Object result = null;
T oldState = state;
try { try {
result = decode(context, channel, replayable, state); result = decode(context, channel, replayable, state);
if (result == null) { if (result == null) {
@ -341,7 +342,7 @@ public abstract class ReplayingDecoder<T extends Enum<T>> extends SimpleChannelH
break; break;
} }
if (oldReaderIndex == cumulation.readerIndex()) { if (oldReaderIndex == cumulation.readerIndex() && oldState == state) {
throw new IllegalStateException( throw new IllegalStateException(
"decode() method must consume at least one byte " "decode() method must consume at least one byte "
+ "if it returned a decoded message."); + "if it returned a decoded message.");