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/04/21 19:09:14 UTC

[GitHub] [kafka] C0urante edited a comment on pull request #10566: KAFKA-12694 Avoid schema mismatch DataException when validating default values

C0urante edited a comment on pull request #10566:
URL: https://github.com/apache/kafka/pull/10566#issuecomment-824292010


   Hmm... I'm wondering if this might break existing setups. Since the `SchemaBuilder` class does implement the `Schema` interface, it's currently possible to do something like this:
   
   ```java
   import org.apache.kafka.connect.data.Schema;
   import org.apache.kafka.connect.data.SchemaBuilder;
   import org.apache.kafka.connect.data.Struct;
   
   SchemaBuilder builder = SchemaBuilder.struct()
       .field("f1", Schema.BOOLEAN_SCHEMA);
   
   Struct defaultValue = new Struct(builder);
   defaultValue.put("f1", true);
   
   Schema schema = builder.defaultValue(defaultValue).build();
   ```
   
   Validation currently uses the equality method of the `Struct`'s schema: https://github.com/apache/kafka/blob/87b24025cedf08c550a180819b2a5a2dbb75f020/connect/api/src/main/java/org/apache/kafka/connect/data/ConnectSchema.java#L247
   which in this case is a `SchemaBuilder` instance that doesn't have an overridden `equals` method, so I think the change proposed here might cause the above example to start to fail.


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