use of com.qcloud.cos.exception.CRC32MismatchException in project cos-java-sdk-v5 by tencentyun.
the class Message method validateMessageCrc.
private static void validateMessageCrc(ByteBuffer buf, int totalLength) {
Checksum crc = new CRC32();
Checksums.update(crc, (ByteBuffer) buf.duplicate().limit(buf.position() + totalLength - 4));
long computedMessageCrc = crc.getValue();
long wireMessageCrc = Utils.toUnsignedLong(buf.getInt(buf.position() + totalLength - 4));
if (wireMessageCrc != computedMessageCrc) {
throw new CosClientException(new CRC32MismatchException(format("Message checksum failure: expected 0x%x, computed 0x%x", wireMessageCrc, computedMessageCrc)));
}
}
Aggregations