int checksum = tmpBuffer.getInt();
int length = tmpBuffer.getShort();
if (length > bytesToBlockEnd || length < 0) {
throw new CorruptDataException("Length is too large:" + length);
}
RecordType type = RecordType.get(tmpBuffer.get());
if (type == RecordType.NONE && length == 0) {
length = bytesToBlockEnd - HEADER_LENGTH;
}
readToTmp(length, false);
if (!isValidCrc(checksum, tmpBuffer, type.value())) {
throw new CorruptDataException("Checksum doesn't validate.");
}
return createRecordFromTmp(type);
}