An Openfire community member contributed this change regarding a problem he was
having in Openfire. I think I like this fix since the CumulativeProtocolDecoder
is not delegating to subclasses to correctly handle decoding when there is
nothing to decode. What do you think? BTW, this is for MINA 1.1.7.
Index:
mina-1.1.7/core/src/main/java/org/apache/mina/filter/codec/CumulativeProtocolDecoder.java
===================================================================
---
mina-1.1.7/core/src/main/java/org/apache/mina/filter/codec/CumulativeProtocolDecoder.java
(revision 1407)
+++
mina-1.1.7/core/src/main/java/org/apache/mina/filter/codec/CumulativeProtocolDecoder.java
(revision 1412)
@@ -128,20 +128,12 @@
usingSessionBuffer = false;
}
- for (;;) {
+ boolean decoded = true;
+ for (;buf.hasRemaining() && decoded;) {
int oldPos = buf.position();
- boolean decoded = doDecode(session, buf, out);
- if (decoded) {
- if (buf.position() == oldPos) {
- throw new IllegalStateException(
- "doDecode() can't return true when buffer is not
consumed.");
- }
-
- if (!buf.hasRemaining()) {
- break;
- }
- } else {
- break;
+ decoded = doDecode(session, buf, out);
+ if (decoded && buf.position() == oldPos) {
+ throw new IllegalStateException("doDecode() can't return true
when buffer is not consumed.");
}
}
Thanks,
-- Gato