release replaying decoder cumulation buffer after firing upstream

This commit is contained in:
Norman Maurer 2011-11-06 20:17:21 +01:00
parent e4bd678846
commit dd8ec0ea30
2 changed files with 13 additions and 0 deletions

View File

@ -504,6 +504,11 @@ public abstract class ReplayingDecoder<T extends Enum<T>>
// 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<T extends Enum<T>>
} catch (ReplayError replay) {
// Ignore
} finally {
replayable = ReplayingDecoderBuffer.EMPTY_BUFFER;
ctx.sendUpstream(e);
}
}

View File

@ -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 <a href="http://www.jboss.org/netty/">The Netty Project</a>
@ -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;
}