chia7712 commented on code in PR #18266:
URL: https://github.com/apache/kafka/pull/18266#discussion_r1891672830
##########
tools/src/main/java/org/apache/kafka/tools/consumer/GroupMetadataMessageFormatter.java:
##########
@@ -37,7 +37,7 @@ public class GroupMetadataMessageFormatter extends
ApiMessageFormatter {
protected JsonNode readToKeyJson(ByteBuffer byteBuffer, short version) {
return readToGroupMetadataKey(byteBuffer)
.map(logKey -> transferKeyMessageToJsonNode(logKey, version))
- .orElseGet(() -> new TextNode(UNKNOWN));
+ .orElseGet(NullNode::getInstance);
Review Comment:
Maybe we can simplify the formatter after removing the unknown.
```java
public class GroupMetadataMessageFormatter extends ApiMessageFormatter {
@Override
protected JsonNode readToKeyJson(ByteBuffer byteBuffer, short ignore) {
short version = byteBuffer.getShort();
if (version >= GroupMetadataKey.LOWEST_SUPPORTED_VERSION && version
<= GroupMetadataKey.HIGHEST_SUPPORTED_VERSION) {
return GroupMetadataKeyJsonConverter.write(new
GroupMetadataKey(new ByteBufferAccessor(byteBuffer), version), version);
}
return NullNode.getInstance();
}
@Override
protected JsonNode readToValueJson(ByteBuffer byteBuffer, short ignore) {
short version = byteBuffer.getShort();
if (version >= GroupMetadataValue.LOWEST_SUPPORTED_VERSION &&
version <= GroupMetadataValue.HIGHEST_SUPPORTED_VERSION) {
return GroupMetadataValueJsonConverter.write(new
GroupMetadataValue(new ByteBufferAccessor(byteBuffer), version), version);
}
return NullNode.getInstance();
}
}
```
##########
tools/src/main/java/org/apache/kafka/tools/consumer/GroupMetadataMessageFormatter.java:
##########
@@ -37,7 +37,7 @@ public class GroupMetadataMessageFormatter extends
ApiMessageFormatter {
protected JsonNode readToKeyJson(ByteBuffer byteBuffer, short version) {
return readToGroupMetadataKey(byteBuffer)
.map(logKey -> transferKeyMessageToJsonNode(logKey, version))
- .orElseGet(() -> new TextNode(UNKNOWN));
+ .orElseGet(NullNode::getInstance);
Review Comment:
the `ignore` can be removed as well
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]