Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-4855

Struct SchemaBuilder should not allow duplicate fields.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 0.10.2.0
    • 0.11.0.0
    • connect

    Description

      I would expect this to fail at the build() on schema. It actually makes it all the way to Struct.validate() and throws a cryptic error message. .field() should throw an exception if a field is already used.

      Repro:

        @Test
        public void duplicateFields() {
          final Schema schema = SchemaBuilder.struct()
              .name("testing")
              .field("id", SchemaBuilder.string().doc("").build())
              .field("id", SchemaBuilder.string().doc("").build())
              .build();
          final Struct struct = new Struct(schema)
              .put("id", "testing");
          struct.validate();
        }
      
      org.apache.kafka.connect.errors.DataException: Invalid value: null used for required field at org.apache.kafka.connect.data.ConnectSchema.validateValue(ConnectSchema.java:212)
      	at org.apache.kafka.connect.data.Struct.validate(Struct.java:232)
      	at io.confluent.kafka.connect.jms.RecordConverterTest.duplicateFieldRepro(RecordConverterTest.java:289)
      

      Attachments

        Issue Links

          Activity

            People

              baluchicken Balint Molnar
              jcustenborder Jeremy Custenborder
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: