Clearing a ByteBuffer
Buffer.clear
resets the position, yes, and then you can use getPosition() > 0
to check if anything has been added to the buffer afterwards, no...?
I resolved a same problem by this code, hope it can help you.
channel1buf.clear();
//zerolize buff manually
channel1buf.put(new byte[1024]);
channel1buf.clear();