vanan08 / unitt

Automatically exported from code.google.com/p/unitt
0 stars 0 forks source link

simple/NetworkSocket.run() overallocates read buffer #33

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. input.available() returns size over 65k (for example 70k)
2. byte array is allocated for 70k bytes
3. input.read() returns 65k bytes
4. 70k buffer (containing 65k valid bytes) is passed to observer class
5. bytes past 65k are null

What is the expected output? What do you see instead?
byte buffer should be allocated after read to exact size

What version of the product are you using? On what operating system?
HEAD on CentOS 6.0

Please provide any additional information below.
can switch to a local permanent buffer; allocate new buffer after read and use 
System.arraycopy to move the bytes.

byte[] bytesIn = new byte[read];
System.arraycopy(readBuffer, 0, bytesIn, 0, read);

Original issue reported on code.google.com by nw...@detroitsci.com on 14 Nov 2011 at 6:23

GoogleCodeExporter commented 9 years ago
Great find! I will be incorporating this into a set of fixes I am currently 
working on. Look for a new build over the weekend.

Original comment by joshuadmorris@gmail.com on 15 Nov 2011 at 12:22

GoogleCodeExporter commented 9 years ago
Sorry for the delay, I am now working on a fix. The holidays are playing havoc 
with my schedule.

Original comment by joshuadmorris@gmail.com on 2 Dec 2011 at 1:19

GoogleCodeExporter commented 9 years ago
Fixed in trunk. I also fixed an error with threading in the same block. :)

Original comment by joshuadmorris@gmail.com on 30 Jan 2012 at 10:33

GoogleCodeExporter commented 9 years ago

Original comment by joshuadmorris@gmail.com on 31 Jan 2012 at 6:32