doydwang / barchart-udt

Automatically exported from code.google.com/p/barchart-udt
0 stars 0 forks source link

SocketUDT receive1 call returns incorrect data #19

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Set up two sockets and send "HELLO" from socket A to server socket B using 
SelectorProviderUDT.DATAGRAM openSocketChannel and openServerSocketChannel
2. Call read on the incoming ChannelSocketUDT on the server, passing it a 
ByteBuffer that's larger than the incoming data

What is the expected output? What do you see instead?
The ByteBuffer should contain "HELLO," but it instead contains "HELLO" plus a 
bunch of other data filled in from the Java class file. Not exactly sure how 
that actually gets there, but the bug is pretty clear on the code level.

Basically, the bug is in src/main/c++/jni/com_barchart_udt_SocketUDT.cpp 
Java_com_barchart_udt_SocketUDT_receive1() and instead of

env->SetByteArrayRegion(arrayObj, position, size, data);

the code should read:

env->SetByteArrayRegion(arrayObj, position, rv, data);

I'll go ahead and commit the fix, but wanted to record the issue.

Original issue reported on code.google.com by adamf...@gmail.com on 26 Jan 2011 at 7:13

GoogleCodeExporter commented 8 years ago
Simple change -- should be all set.

Original comment by adamf...@gmail.com on 26 Jan 2011 at 7:26

GoogleCodeExporter commented 8 years ago
Adam:

thanks for noticing and fixing this;

since current set of unit tests did not catch this,
can you please convert your test code into a new unit test and commit?

thank you

Andrei

Original comment by Andrei.Pozolotin on 26 Jan 2011 at 6:58

GoogleCodeExporter commented 8 years ago
Yes definitely, Andrei -- I'll add it today with a few cleanups to make it a 
proper test.

Original comment by adamf...@gmail.com on 26 Jan 2011 at 9:43

GoogleCodeExporter commented 8 years ago
Just added the unit test, which you can view here:

http://code.google.com/p/barchart-udt/source/browse/trunk/barchart-udt4-parent/b
archart-udt4/src/test/java/com/barchart/udt/SimpleUdtTest.java

Feel free to rename things if you like.

Original comment by adamf...@gmail.com on 26 Jan 2011 at 11:00

GoogleCodeExporter commented 8 years ago
Closing this out again.

Original comment by adamf...@gmail.com on 26 Jan 2011 at 11:00

GoogleCodeExporter commented 8 years ago
very cool, thank you!

bundle 1.0.3 snapshot updated;

Original comment by Andrei.Pozolotin on 27 Jan 2011 at 12:03