Make sure we always cleanup once ReplayingDecoder handles a message. See #259

This commit is contained in:
Norman Maurer 2012-04-20 20:10:50 +02:00
parent 5dbc207b5b
commit f83ba2feb9

View File

@ -294,6 +294,8 @@ public abstract class ReplayingDecoder<T extends Enum<T>>
private ReplayingDecoderBuffer replayable;
private T state;
private int checkpoint;
private boolean needsCleanup;
/**
* Creates a new instance with no initial state (i.e: {@code null}).
@ -430,6 +432,8 @@ public abstract class ReplayingDecoder<T extends Enum<T>>
return;
}
needsCleanup = true;
if (cumulation == null) {
// the cumulation buffer is not created yet so just pass the input
// to callDecode(...) method
@ -571,8 +575,10 @@ public abstract class ReplayingDecoder<T extends Enum<T>>
throws Exception {
try {
ChannelBuffer cumulation = this.cumulation;
if (cumulation == null) {
if (!needsCleanup) {
return;
} else {
needsCleanup = false;
}
this.cumulation = null;