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

SchemaBuilder does not validate input.

Agile BoardAttach filesAttach ScreenshotVotersStop watchingWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.0.0
    • Component/s: KafkaConnect
    • Labels:
      None

      Description

      SchemaBuilder.map(), SchemaBuilder.array(), and SchemaBuilder.field() do not validate input. This can cause weird NullPointerException exceptions later. For example I mistakenly called field("somefield", null), then later performed an operation against field.schema() which yielded a null. It would be preferable to throw an exception stating the issue. We could throw the a NPE but state what is null. Schema is null in this case for example.

        @Test(expected = NullPointerException.class)
        public void fieldNameNull() {
          Schema schema = SchemaBuilder.struct()
              .field(null, Schema.STRING_SCHEMA)
              .build();
        }
      
        @Test(expected = NullPointerException.class)
        public void fieldSchemaNull() {
          Schema schema = SchemaBuilder.struct()
              .field("fieldName", null)
              .build();
        }
      
        @Test(expected = NullPointerException.class)
        public void arraySchemaNull() {
          Schema schema = SchemaBuilder.array(Schema.STRING_SCHEMA)
              .build();
        }
      
        @Test(expected = NullPointerException.class)
        public void mapKeySchemaNull() {
          Schema schema = SchemaBuilder.map(null, Schema.STRING_SCHEMA)
              .build();
        }
      
        @Test(expected = NullPointerException.class)
        public void mapValueSchemaNull() {
          Schema schema = SchemaBuilder.map(Schema.STRING_SCHEMA, null)
              .build();
        }
      

        Attachments

          Activity

            People

            • Assignee:
              jcustenborder Jeremy Custenborder
              Reporter:
              jcustenborder Jeremy Custenborder

              Dates

              • Created:
                Updated:
                Resolved:

                Issue deployment