code: public int readTag() throws IOException {
      if (isAtEnd()) {
        lastTag = 0;
        return 0;
      }
  
      lastTag = readRawVarint32();
      if (WireFormat.getTagFieldNumber(lastTag) == 0) {
        // If we actually read zero (or any tag number corresponding to field
        // number zero), that's not a valid tag.
        throw InvalidProtocolBufferException.invalidTag();
      }
      return lastTag;
    }
docs: 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.