brandboat commented on code in PR #18510: URL: https://github.com/apache/kafka/pull/18510#discussion_r1914066204
########## tools/src/main/java/org/apache/kafka/tools/consumer/ApiMessageFormatter.java: ########## @@ -79,5 +79,5 @@ public void writeTo(ConsumerRecord<byte[], byte[]> consumerRecord, PrintStream o } protected abstract JsonNode readToKeyJson(ByteBuffer byteBuffer); - protected abstract JsonNode readToValueJson(ByteBuffer byteBuffer); -} + protected abstract JsonNode readToValueJson(ByteBuffer byteBuffer, short keyVersion); Review Comment: Yes, I've thought about that before, but that means we need to add below methods to `ApiMessageFormatter.java`. ```java protected abstract JsonNode readToValueJson(ByteBuffer byteBuffer); protected JsonNode readToValueJson(ByteBuffer byteBuffer, short keyVersion) { return readToValueJson(byteBuffer); } ``` But doing that means I need to override two methods in ShareGroupStateMessageFormatter.java, particularly readToValueJson(ByteBuffer byteBuffer). This method will essentially be a dummy method, which feels somewhat awkward to implement, so I decided to add an extra parameter to it instead. ```java @Override protected JsonNode readToValueJson(ByteBuffer byteBuffer, short keyVersion) { short valueVersion = byteBuffer.getShort(); return readToSnapshotMessageValue(byteBuffer, keyVersion, valueVersion) .map(logValue -> transferValueMessageToJsonNode(logValue, valueVersion)) .orElseGet(() -> new TextNode(UNKNOWN)); } @Override protected JsonNode readToValueJson(ByteBuffer byteBuffer) { return null; } ``` Or you have other ideas? Let me know if you'd like any further adjustments! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org