Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
cpeterso
on May 28, 2012
|
parent
|
context
|
favorite
| on:
A bug I won't forget
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.
fizx
on May 29, 2012
[–]
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.
i386
on May 29, 2012
|
parent
[–]
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.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: