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 5103ded6dc..9b85c8b985 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 @@ -504,6 +504,11 @@ public abstract class ReplayingDecoder> // A successful decode unfoldAndFireMessageReceived(context, result, remoteAddress); + + if (!cumulation.readable()) { + this.cumulation.set(null); + replayable = ReplayingDecoderBuffer.EMPTY_BUFFER; + } } } @@ -551,6 +556,7 @@ public abstract class ReplayingDecoder> } catch (ReplayError replay) { // Ignore } finally { + replayable = ReplayingDecoderBuffer.EMPTY_BUFFER; ctx.sendUpstream(e); } } diff --git a/src/main/java/org/jboss/netty/handler/codec/replay/ReplayingDecoderBuffer.java b/src/main/java/org/jboss/netty/handler/codec/replay/ReplayingDecoderBuffer.java index 2cae1b55b2..8f801f9b04 100644 --- a/src/main/java/org/jboss/netty/handler/codec/replay/ReplayingDecoderBuffer.java +++ b/src/main/java/org/jboss/netty/handler/codec/replay/ReplayingDecoderBuffer.java @@ -27,6 +27,7 @@ import java.nio.charset.Charset; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBufferFactory; import org.jboss.netty.buffer.ChannelBufferIndexFinder; +import org.jboss.netty.buffer.ChannelBuffers; /** * @author The Netty Project @@ -42,6 +43,12 @@ class ReplayingDecoderBuffer implements ChannelBuffer { private final ChannelBuffer buffer; private boolean terminated; + public static ReplayingDecoderBuffer EMPTY_BUFFER = new ReplayingDecoderBuffer(ChannelBuffers.EMPTY_BUFFER); + + static { + EMPTY_BUFFER.terminate(); + } + ReplayingDecoderBuffer(ChannelBuffer buffer) { this.buffer = buffer; }