[muscle] Java NIO bugs...

  • From: Bryan Varner <bryan@xxxxxxxxxxxxx>
  • To: muscle@xxxxxxxxxxxxx
  • Date: Tue, 2 Sep 2014 13:41:39 -0400

I recently upgraded some very old java MUSCLE code to the interfaces using the 
Java NIO byte buffers, and found some unexpected results.

Specifically, I was getting IOExceptions as if the remote end of the connection 
had hung-up. After a lot of sleuthing, I found that the receive buffer position 
wasn’t being set prior to throwing a NotEnoughDataException during message 
unflattening, which was leaving the buffer in an inconsistent state and 
basically reading random bits into bytes for message length and encoding…

I ran across the root of the problem after noticing that the byte buffers were 
being allocated per message received invocation, and were using indirect byte 

I have a copy of the source with the issue fixed as well as a set of changes 
which changes the scope of the byte buffer, allocated it as direct, and 
dramatically reduced the amount of work the GC was doing in Java to clean up 
all those byte buffer allocations.

What’s the process for submitting patches these days? :-)


Other related posts: