m1a2st commented on code in PR #19869: URL: https://github.com/apache/kafka/pull/19869#discussion_r2123355432
########## connect/api/src/main/java/org/apache/kafka/connect/data/Values.java: ########## @@ -1273,9 +1254,7 @@ public boolean canDetect(Object value) { } if (knownType == null) { knownType = schema.type(); - } else if (knownType != schema.type()) { - return false; - } + } else return knownType == schema.type(); return true; Review Comment: How about ``` if (knownType == null) { knownType = schema.type(); return true; } else { return knownType == schema.type(); } ``` ########## connect/api/src/test/java/org/apache/kafka/connect/data/ConnectSchemaTest.java: ########## @@ -311,13 +312,13 @@ public void testStructEquality() { // Same as testArrayEquality, but checks differences in fields. Only does a simple check, relying on tests of // Field's equals() method to validate all variations in the list of fields will be checked ConnectSchema s1 = new ConnectSchema(Schema.Type.STRUCT, false, null, null, null, null, null, - Arrays.asList(new Field("field", 0, SchemaBuilder.int8().build()), + List.of(new Field("field", 0, SchemaBuilder.int8().build()), new Field("field2", 1, SchemaBuilder.int16().build())), null, null); ConnectSchema s2 = new ConnectSchema(Schema.Type.STRUCT, false, null, null, null, null, null, - Arrays.asList(new Field("field", 0, SchemaBuilder.int8().build()), + List.of(new Field("field", 0, SchemaBuilder.int8().build()), new Field("field2", 1, SchemaBuilder.int16().build())), null, null); ConnectSchema differentField = new ConnectSchema(Schema.Type.STRUCT, false, null, null, null, null, null, - Arrays.asList(new Field("field", 0, SchemaBuilder.int8().build()), + List.of(new Field("field", 0, SchemaBuilder.int8().build()), new Field("different field name", 1, SchemaBuilder.int16().build())), null, null); assertEquals(s1, s2); Review Comment: L384 `Arrays.asList` also need to transfer to `List.of()` L380 `Collections.emptyList()` L381 `Collections.singletonList("hello")` L389 `Collections.singletonList(true)` Please double-check this file ########## connect/api/src/test/java/org/apache/kafka/connect/header/ConnectHeadersTest.java: ########## @@ -380,9 +381,9 @@ public void shouldValidateBuildInTypes() { assertSchemaMatches(Schema.FLOAT64_SCHEMA, 1.0d); assertSchemaMatches(Schema.STRING_SCHEMA, "value"); assertSchemaMatches(SchemaBuilder.array(Schema.STRING_SCHEMA), new ArrayList<String>()); - assertSchemaMatches(SchemaBuilder.array(Schema.STRING_SCHEMA), Collections.singletonList("value")); + assertSchemaMatches(SchemaBuilder.array(Schema.STRING_SCHEMA), List.of("value")); assertSchemaMatches(SchemaBuilder.map(Schema.STRING_SCHEMA, Schema.INT32_SCHEMA), new HashMap<String, Integer>()); - assertSchemaMatches(SchemaBuilder.map(Schema.STRING_SCHEMA, Schema.INT32_SCHEMA), Collections.singletonMap("a", 0)); + assertSchemaMatches(SchemaBuilder.map(Schema.STRING_SCHEMA, Schema.INT32_SCHEMA), Map.of("a", 0)); Review Comment: L506 `List.of()` -- 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