Test:
call org.bson.io.Bits.readFully(new ByteArrayInputStream("some sample text".getBytes()), new byte[20], 0, 10);
Expected:
10 bytes are read.
Observed:
java.lang.IllegalArgumentException: Buffer is too small
The safety check
if (b.length - startOffset > length)
should test for "<".