From 90e32e3bc4646cccd3b22cbf2b4c24027f44e7e4 Mon Sep 17 00:00:00 2001 From: kedixa <1204837541@qq.com> Date: Wed, 8 Jan 2025 20:40:24 +0800 Subject: [PATCH] fix KafkaMessage::parse_record_batch (#1680) * fix KafkaMessage::parse_record_batch * use compress_type instead of compressed --- src/protocol/KafkaMessage.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/protocol/KafkaMessage.cc b/src/protocol/KafkaMessage.cc index af06e7ec08..05c184eff4 100644 --- a/src/protocol/KafkaMessage.cc +++ b/src/protocol/KafkaMessage.cc @@ -1450,10 +1450,11 @@ int KafkaMessage::parse_record_batch(void **buf, size_t *size, return 1; KafkaBlock block; + int compress_type = hdr.attributes & 7; - if (hdr.attributes & 7) + if (compress_type != 0) { - if (uncompress_buf(*buf, hdr.length - 61 + 12, &block, hdr.attributes & 7) < 0) + if (uncompress_buf(*buf, hdr.length - 61 + 12, &block, compress_type) < 0) return -1; *buf = (char *)*buf + hdr.length - 61 + 12; @@ -1492,7 +1493,7 @@ int KafkaMessage::parse_record_batch(void **buf, size_t *size, } } - if (hdr.attributes == 0) + if (compress_type == 0) { *buf = p; *size = n;