News for hackers. Stuff that matters.
Re: A bug I won't forget by cpeterso on Monday May 28, 2012 @03:08PM (#4034571)
Were you or the network library reusing buffer objects (to avoid reallocating them), so the random data was leftover from an early socket read? I'm surprised the JVM would allocate a new buffer object with non-zero data.
Re: A bug I won't forget by fizx on Monday May 28, 2012 @08:27PM (#4035475)
Yeah, he was almost certainly reusing his byte[]s. My takeaway is that if you program a high-level language as if it's C, expect C-like bugs.
Re: A bug I won't forget by i386 on Monday May 28, 2012 @10:29PM (#4035676)
Likely reusing his directly allocated ByteBuffer and not checking the number of bytes that he filled it with.

From what I remember, directly allocated ByteBuffers are not guaranteed to be zeroed.