public int readTag() throws IOException {
        if (!nioBuffer.hasRemaining()) {
            lastTag = 0;
            return 0;
        }

        final int tag = readRawVarInt32();
        if (tag >>> TAG_TYPE_BITS == 0) {
            // If we actually read zero, that's not a valid tag.
            throw ProtocolException.invalidTag();
        }
        lastTag = tag;
        return tag;
    }
Attempt to read a field tag, returning zero if we have reached EOF. Protocol message parsers use this to read
tags, since a protocol message may legally end wherever a tag occurs, and zero is not a valid tag number.
jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/serialization/impl/protostuff/io/UnsafeNioBufInput.java