@Override
    public int indexOf(int fromIndex, int toIndex, byte value) {
        if (fromIndex <= toIndex) {
            return ByteBufUtil.firstIndexOf(this, fromIndex, toIndex, value);
        }
        return ByteBufUtil.lastIndexOf(this, fromIndex, toIndex, value);
    }
@Test
    public void testIndexOfReleaseBuffer() {
        ByteBuf buffer = releasedBuffer();
        if (buffer.capacity() != 0) {
            try {
                buffer.indexOf(0, 1, (byte) 1);
                fail();
            } catch (IllegalReferenceCountException expected) {
                // expected
            }
        } else {
            assertEquals(-1, buffer.indexOf(0, 1, (byte) 1));
        }
    }