I've seen this problem in the past, and I'm seeing it again... If one extends the CumulativeDecoder and finds that there is not enough data in the buffer, one returns false on doDecode() so mina can collect more data. However, it seems that CumulativeDecoder puts the last remaining bytes from the decode into an UnderivableBuffer and stores it in the session. When it gets more data later, the data is added to this session buffer, and the CumulativeDecoder subclass gets to it.
The problem is, things like slice() and duplicate() on an UnderivableBuffer throw an exception. Therefore, your cumulative decoder that does slice() will result in an exception. Is this by design? Should you write your cumulative decoder in such a way one should never call slice()? This is somewhat unexpected because Mina 1.1 did not have such a restriction. The example class named CrLfTerminatedCommandLineDecoder mentioned in the javadoc of CumulativeDecoder also uses IoBuffer.slice(). I wrote a quick test that exercises this class, and as expected, I get an UnsupportedOperationException saying buffer derivation is disabled. Any thoughts on this? Does one need to find a way to use the CumulativeDecoder that avoids these methods? Thanks, Sangjin
