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

Struct.put() should include the field name if validation fails

    XMLWordPrintableJSON

    Details

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

      Description

      When calling struct.put() with an invalid value, the error message should include the field name.

      @Test
      public void testPutIncludesFieldName() {
          final String fieldName = "fieldName";
          Schema testSchema = SchemaBuilder.struct()
              .field(fieldName, Schema.STRING_SCHEMA);
          Struct struct = new Struct(testSchema);
          try {
              struct.put(fieldName, null);
          } catch (DataException ex) {
              assertEquals(
                  "Invalid value: null used for required field: \"fieldName\", schema type: STRING",
                  ex.getMessage()
              );
          }
      
      }
      

        Attachments

          Activity

            People

            • Assignee:
              jcustenborder Jeremy Custenborder
              Reporter:
              jcustenborder Jeremy Custenborder
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: