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 2021/03/01 15:34:57 UTC

[GitHub] [kafka] C0urante commented on a change in pull request #9541: KAFKA-10675: Add schema name to ConnectSchema.validateValue() error message

C0urante commented on a change in pull request #9541:
URL: https://github.com/apache/kafka/pull/9541#discussion_r584810742



##########
File path: connect/api/src/main/java/org/apache/kafka/connect/data/ConnectSchema.java
##########
@@ -266,10 +261,19 @@ public static void validateValue(String name, Schema schema, Object value) {
     private static List<Class> expectedClassesFor(Schema schema) {
         List<Class> expectedClasses = LOGICAL_TYPE_CLASSES.get(schema.name());
         if (expectedClasses == null)
-            expectedClasses = SCHEMA_TYPE_CLASSES.get(schema.type());
+            expectedClasses = SCHEMA_TYPE_CLASSES.getOrDefault(schema.type(), Collections.emptyList());
         return expectedClasses;
     }
 
+    private static String buildSchemaInfo(Schema schema) {
+        StringBuilder schemaInfo = new StringBuilder("schema");
+        if (schema.name() != null) {
+            schemaInfo.append(" \"").append(schema.name()).append("\"");
+        }
+        schemaInfo.append(" with type ").append(schema.type());
+        return schemaInfo.toString();
+    }

Review comment:
       Given that this is only used in one place, and the string that it creates is itself added to a formatted string, I think it'd be a bit more readable if we removed this method and inlined all the logic where it's being invoked right now.




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