@Override
    @Nullable
    public byte[] readByteArray() throws IOException {
        int len = readInt();
        if (len == NULL_ARRAY_LENGTH) {
            return null;
        }
        if (len > 0) {
            byte[] b = new byte[len];
            readFully(b);
            return b;
        }
        return EMPTY_BYTE_ARRAY;
    }
@Test
    public void testReadByteArray() throws Exception {
        byte[] bytesBE = {0, 0, 0, 0, 0, 0, 0, 1, 1, 9, -1, -1, -1, -1};
        byte[] bytesLE = {0, 0, 0, 0, 1, 0, 0, 0, (byte) 1, 9, -1, -1, -1, -1};
        in.init((byteOrder == BIG_ENDIAN ? bytesBE : bytesLE), 0);

        in.position(10);
        byte[] theNullArray = in.readByteArray();
        in.position(0);
        byte[] theZeroLengthArray = in.readByteArray();
        in.position(4);
        byte[] bytes = in.readByteArray();

        assertNull(theNullArray);
        assertArrayEquals(new byte[0], theZeroLengthArray);
        assertArrayEquals(new byte[]{1}, bytes);
    }