# read_boolean() now only adjusts positions if the chunk_end_pos == pos, no longer calling
# handle_chunking(). The problem with handle_chunking() is that it aligns the current position
# and this can cause CDRInputStream to "skip" valid boolean values, as those are not padded.

--- src/org/jacorb/orb/CDRInputStream.java	2009-05-03 18:35:54.000000000 -0300
+++ src/org/jacorb/orb/CDRInputStream.java	2009-07-27 21:43:13.654728303 -0300
@@ -460,51 +460,52 @@
 
     private final void handle_chunking()
     {
-        int remainder = 4 - (index % 4);
-        int aligned_pos = (remainder != 4) ? pos + remainder : pos;
+        int remainder = 4 - (this.index % 4);
+        int aligned_pos = (remainder != 4) ? this.pos + remainder : this.pos;
 
-        if (chunk_end_pos >= pos && chunk_end_pos <= aligned_pos)
+        if (this.chunk_end_pos >= pos && this.chunk_end_pos <= aligned_pos)
         {
-            chunk_end_pos = -1;
-            int saved_pos = pos;
-            int saved_index = index;
-            int tag = read_long();
+            this.adjust_positions();
+        }
+    }
 
-            if (tag < 0) {
+    private final void adjust_positions()
+    {
+        this.chunk_end_pos = -1;
+        int saved_pos = this.pos;
+        int saved_index = this.index;
+        int tag = this.read_long();
 
+        if (tag < 0) 
+        {
                 // tag is an end tag
-
-                if (-tag > valueNestingLevel)
+            if (-tag > this.valueNestingLevel)
                 {
                     throw new INTERNAL
                     (
                         "received end tag " + tag +
                         " with value nesting level " +
-                        valueNestingLevel
+                    this.valueNestingLevel
                     );
                 }
-                valueNestingLevel = -tag;
-                valueNestingLevel--;
-
-                if (valueNestingLevel > 0)
+            this.valueNestingLevel = -tag;
+            this.valueNestingLevel--;
+  	    if (this.valueNestingLevel > 0)
                 {
-                    chunk_end_pos = pos;
-                    handle_chunking();
+                this.chunk_end_pos = pos;
+                this.handle_chunking();
                 }
             }
             else if (tag > 0 && tag < 0x7fffff00)
             {
                 // tag is the chunk size tag of another chunk
-
-                chunk_end_pos = pos + tag;
+            this.chunk_end_pos = this.pos + tag;
             }
             else // (tag == 0 || tag >= 0x7fffff00)
             {
                 // tag is the null value tag or the value tag of a nested value
-
-                pos = saved_pos;      // "unread" the tag
-                index = saved_index;
-            }
+            this.pos = saved_pos;      // "unread" the tag
+            this.index = saved_index;
         }
     }
 
@@ -711,7 +712,11 @@
 
     public final boolean read_boolean()
     {
-        handle_chunking();
+        // handle_chunking();
+        if (this.chunk_end_pos == this.pos)
+        {
+            this.adjust_positions();
+        }
         index++;
         byte value = buffer[pos++];
 
