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.
   
   A naive solution could be to modify the validation to be something like `if 
(!schema.equals(struct.schema()))` but that may introduce other edge cases. Can 
you provide a brief example of what sort of connector code ran into this bug in 
the first place? That might help guide the path forward.


-- 
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:
us...@infra.apache.org


Reply via email to