You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2020/12/15 01:10:27 UTC

[GitHub] [kafka] chia7712 commented on a change in pull request #9748: MINOR: Simplify ApiKeys by relying on ApiMessageType and removing unused methods

chia7712 commented on a change in pull request #9748:
URL: https://github.com/apache/kafka/pull/9748#discussion_r542962306



##########
File path: generator/src/main/java/org/apache/kafka/message/ApiMessageTypeGenerator.java
##########
@@ -169,7 +169,7 @@ private void generateEnumValues() {
     }
 
     private void generateInstanceVariables() {
-        buffer.printf("private final String name;%n");
+        buffer.printf("public final String name;%n");

Review comment:
       It is a bit weird that ```messageType.name``` and ```messageType.name()``` return different string.

##########
File path: clients/src/test/java/org/apache/kafka/common/message/MessageTest.java
##########
@@ -952,40 +904,6 @@ public String toString() {
         }
     }
 
-    private static void compareTypes(Schema schemaA, Schema schemaB) {
-        compareTypes(new NamedType("schemaA", schemaA),
-                     new NamedType("schemaB", schemaB));
-    }
-
-    private static void compareTypes(NamedType typeA, NamedType typeB) {
-        List<NamedType> listA = flatten(typeA);
-        List<NamedType> listB = flatten(typeB);
-        if (listA.size() != listB.size()) {
-            throw new RuntimeException("Can't match up structures: typeA has " +
-                Utils.join(listA, ", ") + ", but typeB has " +
-                Utils.join(listB, ", "));
-        }
-        for (int i = 0; i < listA.size(); i++) {
-            NamedType entryA = listA.get(i);
-            NamedType entryB = listB.get(i);
-            if (!entryA.hasSimilarType(entryB)) {
-                throw new RuntimeException("Type " + entryA + " in schema A " +
-                    "does not match type " + entryB + " in schema B.");
-            }
-            if (entryA.type.isNullable() != entryB.type.isNullable()) {
-                throw new RuntimeException(String.format(
-                    "Type %s in Schema A is %s, but type %s in " +
-                        "Schema B is %s",
-                    entryA, entryA.type.isNullable() ? "nullable" : "non-nullable",
-                    entryB, entryB.type.isNullable() ? "nullable" : "non-nullable"));
-            }
-            if (entryA.type.isArray()) {
-                compareTypes(new NamedType(entryA.name, entryA.type.arrayElementType().get()),
-                             new NamedType(entryB.name, entryB.type.arrayElementType().get()));
-            }
-        }
-    }
-
     /**

Review comment:
       this method is never used.

##########
File path: clients/src/main/java/org/apache/kafka/common/protocol/ApiKeys.java
##########
@@ -343,9 +174,15 @@ public Struct parseResponse(short version, ByteBuffer buffer) {
                 throw new IllegalStateException("Response schema for api " + name + " for version " + i + " is null");
         }
 
+        this.messageType = messageType;
+        this.id = id;
+        this.name = name;

Review comment:
       Could we fix the comment about "name" as it is used to be a part of metrics name (see https://github.com/apache/kafka/blob/trunk/core/src/main/scala/kafka/network/RequestChannel.scala#L239). The origin comment is stale.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org