You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@mina.apache.org by Alexander Christian <al...@root1.de> on 2009/12/02 21:40:39 UTC

BufferUnderFlowException in org.apache.mina.filter.codec.ProtocolCodecFilter

Hi guys,

I created a nice RMI alternative based on MINA 2.0 RC1 called "SIMON". 
(http://dev.root1.de/projects/show/simon).

This works fine so far and is already used in some bigger tests. Now I 
wanted to create a massive multithreaded test:

With "SIMON" words: One Client-Application that simulates 60 Clients 
(---> 60 threads). Each "client"  sends several messages to the server 
until it terminates.

In "MINA" words: I have one client->server connection, 60 worker threads 
on client side that send and receive several messages until they 
terminate, and I make use of my own ProtocolCodecFactory.

The problem now is:

I can do the above test with 10 threads. No problem. If I increase the 
number of threads that send and receive messages through the 
protocolcodec, I sooner or later get the following exception (everytime 
the same stack):

-----
2009-12-02 21:16:11,786 [FINEST    ] t_id=63 
de.root1.simon.Dispatcher.exceptionCaught -> exception Caught. 
session=0x00000003 
cause=org.apache.mina.filter.codec.ProtocolDecoderException: 
java.nio.BufferUnderflowException (Hexdump: 01 00 00 00 26 00 00 00 01 
00 20 64 65 2E 72 6F 6F 74 31 2E 73 69 6D 6F 6E 2E 74 65 73 74 2E 52 65 
6D 6F 74 65 4F 62 6A 65 63 74 00 03 7B 23 7D 01 00 00 00 25 00 00 00 01 
00 20 64 65 2E 72 6F 6F 74 31 2E 73 69 6D 6F 6E 2E 74 65 73 74 2E 52 65 
6D 6F 74 65 4F 62 6A 65 63 74 00 03 7B 23 7D 01 00 00 00 24 00 00 00 01 
00 20 64 65 2E 72 6F 6F 74 31 2E 73 69 6D 6F 6E 2E 74 65 73 74 2E 52) stack=
org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:235)
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)
org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46)
org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:793)
org.apache.mina.filter.logging.LoggingFilter.messageReceived(LoggingFilter.java:176)
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)
org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46)
org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:793)
org.apache.mina.core.filterchain.IoFilterAdapter.messageReceived(IoFilterAdapter.java:119)
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)
org.apache.mina.core.filterchain.DefaultIoFilterChain.fireMessageReceived(DefaultIoFilterChain.java:426)
org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:638)
org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:598)
org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:587)
org.apache.mina.core.polling.AbstractPollingIoProcessor.access$400(AbstractPollingIoProcessor.java:61)
org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:969)
org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
java.lang.Thread.run(Thread.java:619)
-----
(The "Dispatcher" class is an instance of IoHandler)

I've no idea what causes this bufferunderflow. And i've no idea how to 
track down the root of this issue (the stack does only show mina classes 
..).

So my question is:

If I use a ProtocolCodecFactory and get into trouble with 
bufferunderflow somewhere in the mina code: Is it possible that MINA has 
a problem? Or is it only my code?

As the constellation is quite "complex" it's not easy to provide a 
reproducer-sample.... So how can I proceed analyzing this issue to find 
the root-cause?


best regards,
Alex



Re: BufferUnderFlowException in org.apache.mina.filter.codec.ProtocolCodecFilter

Posted by Emmanuel Lecharny <el...@gmail.com>.
Alexander Christian a écrit :
> Hi guys,
>
>
<snip/>
> I've no idea what causes this bufferunderflow. And i've no idea how to 
> track down the root of this issue (the stack does only show mina 
> classes ..).
"Unchecked exception thrown when a relative get operation reaches the 
source buffer's limit. "

Basically, you try to do a get()on the IoBuffer but there is nothing 
left into it.

Remember that you may perfectly receive your message in small pieces, 
and you will have to reassemble them before being able to decode it.

>