gunnarmorling commented on pull request #10566:
URL: https://github.com/apache/kafka/pull/10566#issuecomment-895027031
Hey @C0urante,
```
Struct defaultValue = new Struct(builder);
```
Initializing a `Struct` with a builder rather than a `Schema` seems to be an
odd thing to do, no? Here's an example for triggering the exception we ran
into, without the proposed change:
```
SchemaBuilder builder = SchemaBuilder.struct()
.field("f1", Schema.BOOLEAN_SCHEMA);
Struct defaultValue = new Struct(builder.build()); // the Struct receives a
schema, not a builder
defaultValue.put("f1", true);
builder.defaultValue(defaultValue)
.build();
```
I think ultimately this exposes sort of a gap in the KC schema API, as
there's a recursive relationship between struct and schema in the default value
case. The suggested change should improve the situation though for the IMO more
common case where a `Struct` is initialized with a `Schema` rather than a
`SchemaBuilder`.
@C0urante, @rhauch, any thoughts?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]