private void startChecksum(ByteBuffer dataBuffer, boolean isChecksumTarget) throws ChecksumException { if (!doChecksumOnRead) { return; } if (!isChecksumTarget) { return; } /* Clear out any previous data. */ cksumValidator.reset(); int originalPosition = threadSafeBufferPosition(dataBuffer); if (currentEntryHeader.isInvisible()) { /* * Turn off invisibility so that the checksum will succeed. When * entries are made invisible, the checksum is not adjusted. Note * that the dataBuffer can leave the invisible bit transformed, * because the header has already been initialized, and this data * will never be read again. */ LogEntryHeader.turnOffInvisible( dataBuffer, originalPosition - LogEntryHeader.MIN_HEADER_SIZE); } /* Position the buffer at the start of the data, after the checksum. */ int headerSizeMinusChecksum = currentEntryHeader.getInvariantSizeMinusChecksum(); int entryTypeStart = originalPosition - headerSizeMinusChecksum; threadSafeBufferPosition(dataBuffer, entryTypeStart); /* Load the validate with the header bytes. */ cksumValidator.update(dataBuffer, headerSizeMinusChecksum); /* Move the data buffer back to the original position. */ threadSafeBufferPosition(dataBuffer, originalPosition); }