users@grizzly.java.net

Bugs with Buffer.disposeUnused in Grizzly 2.0?

From: Bo Li <b.li_at_sun.com>
Date: Mon, 22 Mar 2010 19:56:58 -0500

I noticed after introducing disposeUnsed, SSL connections no longer works. I tracked the first one down to the getBufferIndex method in BuffersBuffer:

Index: modules/grizzly/src/main/java/com/sun/grizzly/memory/BuffersBuffer.java
===================================================================
--- modules/grizzly/src/main/java/com/sun/grizzly/memory/BuffersBuffer.java (revision 4345)
+++ modules/grizzly/src/main/java/com/sun/grizzly/memory/BuffersBuffer.java Mon Mar 22 16:58:06 CDT 2010
@@ -1281,7 +1281,7 @@
                 return makeLocation(i, buffer.position() + steps);
             }
 
- steps -= buffer.remaining();
+ steps -= buffer.limit();
         }
 
         if (steps == 0) {


However, now I'm getting the following exception:

WARNING: Exception during FilterChain execution
java.lang.IndexOutOfBoundsException: Limit 17192 is out of bounds
        at com.sun.grizzly.memory.BuffersBuffer.locateBufferLimit(BuffersBuffer.java:1339)
        at com.sun.grizzly.memory.BuffersBuffer.disposeUnused(BuffersBuffer.java:386)
        at com.sun.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:312)
        at com.sun.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:225)
        at com.sun.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:178)
        at com.sun.grizzly.ProcessorExecutor.resume(ProcessorExecutor.java:73)
        at com.sun.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:61)
        at com.sun.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:634)
        at com.sun.grizzly.strategies.WorkerThreadStrategy$1.run(WorkerThreadStrategy.java:116)
        at com.sun.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:417)
        at com.sun.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:398)
        at java.lang.Thread.run(Thread.java:637)

I tried to figure out what locateBufferLimit does but it doesn't seem clear. My BuffersBuffer is composed of 13 Buffers of whose limit = 1228, pos = 1228, cap = 1228. The last buffer has a limit = 1228, pos = 0, cap = 1228.

Is this a bug with locateBufferLimit or something else?

Thanks
Bo