void sanityCheck() throws IOException {
    // Duplicate so no side-effects
    ByteBuff dup = this.bufWithoutChecksum.duplicate().rewind();
    sanityCheckAssertion(BlockType.read(dup), blockType);

    sanityCheckAssertion(dup.getInt(), onDiskSizeWithoutHeader, "onDiskSizeWithoutHeader");

    sanityCheckAssertion(dup.getInt(), uncompressedSizeWithoutHeader,
      "uncompressedSizeWithoutHeader");

    sanityCheckAssertion(dup.getLong(), prevBlockOffset, "prevBlockOffset");
    if (this.fileContext.isUseHBaseChecksum()) {
      sanityCheckAssertion(dup.get(), this.fileContext.getChecksumType().getCode(), "checksumType");
      sanityCheckAssertion(dup.getInt(), this.fileContext.getBytesPerChecksum(),
        "bytesPerChecksum");
      sanityCheckAssertion(dup.getInt(), onDiskDataSizeWithHeader, "onDiskDataSizeWithHeader");
    }

    if (dup.limit() != onDiskDataSizeWithHeader) {
      throw new AssertionError(
        "Expected limit " + onDiskDataSizeWithHeader + ", got " + dup.limit());
    }

    // We might optionally allocate HFILEBLOCK_HEADER_SIZE more bytes to read the next
    // block's header, so there are two sensible values for buffer capacity.
    int hdrSize = headerSize();
    dup.rewind();
    if (
      dup.remaining() != onDiskDataSizeWithHeader
        && dup.remaining() != onDiskDataSizeWithHeader + hdrSize
    ) {
      throw new AssertionError("Invalid buffer capacity: " + dup.remaining() + ", expected "
        + onDiskDataSizeWithHeader + " or " + (onDiskDataSizeWithHeader + hdrSize));
    }
  }
Checks if the block is internally consistent, i.e. the first
{@link HConstants#HFILEBLOCK_HEADER_SIZE} bytes of the buffer contain a valid header consistent
with the fields. Assumes a packed block structure. This function is primary for testing and
debugging, and is not thread-safe, because it alters the internal buffer pointer. Used by tests
only.
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileBlock.java