Export to GitHub

merapi - issue #2

Old messages are processed multiple times, due to a problem in message buffer management.


Posted on May 22, 2009 by Happy Ox

What steps will reproduce the problem? 1. Send a first message from Java to ActionScript. 2. In ActionScript, the message is received and processed. 3. Send another message from Java to ActionScript. 4. In ActionScript, both the first and new message are processed (even if the first one was already handled by the MessageHandler).

What is the expected output? What do you see instead? Already processed messages should not be processed again.

IMO, the receive buffer is not being cleared after an entire messages has arrived. We should keep the buffer content (resetting the position to zero and appending new data to the end) only while we have only a partial message - and clear it on each fully received one.

Comment #1

Posted on May 27, 2009 by Swift Monkey

Fixed in [11]

Comment #2

Posted on Jun 4, 2009 by Swift Monkey

(No comment was entered for this change.)

Comment #3

Posted on Jun 4, 2009 by Happy Ox

Sorry, I hadn't time to check the committed fix. However i've compared the code with my own fix and it is the same, so i think that the bug has been fixed :) (my code has also the fix for the message lenght).

Comment #4

Posted on Jun 4, 2009 by Swift Monkey

Great.. could you submit your fix to merapi.patches@gmail.com?

much appreciated, -adam

Comment #5

Posted on Jun 4, 2009 by Happy Ox

The fix for the message length is quite "brute": for now I've used an Amf3Output class instance directly from the sendMessage(...) method... I think that a better way could be to use a cached Amf3Output (like the class used to encode the message, but now I don't remenber how it was). Insteand, the use of Integer instead of Byte to send and read the message length is required, b/c the getByte() in ActionScript return a number that isn't big enough to fit a Java long type. Tomorrow if I found some time I'll send the "brute" fix :).

Bye, Luca

Status: Fixed