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