Lately I’'ve tried to understand how was working MINA within Wildfire.
While looking at the XMPPDecoder I beleive that MINA usage could be improved.
You’'re using a CumulativeProtocolDecoder which is intended to decode incoming byte as they arrived. Data is kept in an internal buffer until there is enough data to found one stanza.
Looking at MINA documentation you should return:
true if and only if there’'s more to decode in the buffer and you want to have doDecode method invoked again.
false if remaining data is not enough to decode, then this method will be invoked again when more data is cumulated
To decode incoming traffic the class XMLLightweightParser is used. When calling pareser.read it removes all the data from the MINA’'s byte buffer and put it in his own buffer.
After this you return true, which means that some more data need to be processed but all the data has been removed from the bytebuffer. This typically has no use.
Furthermore the use of (in.remaining() Message won’'t be treated until more data is received
My recommendation will be to use a ProtocolDecoderAdapter which is the BaseClass of the CumulativeProtocolDecoder.
This is a patch on today’'s trunk that should solve this issue.
What do you think?