IIUC, ProtocolCodecFilter is calling ProtocolDecoder.decode() even when the buffer is empty, right?

On Sat, 17 May 2008 02:29:46 +0900, Gaston Dombiak <[EMAIL PROTECTED]> wrote:

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




--
Trustin Lee - Principal Software Engineer, JBoss, Red Hat
--
what we call human nature is actually human habit
--
http://gleamynode.net/

Reply via email to