kafka-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ewen Cheslack-Postava (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (KAFKA-5548) SchemaBuilder does not validate input.
Date Sat, 01 Jul 2017 09:48:03 GMT

     [ https://issues.apache.org/jira/browse/KAFKA-5548?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Ewen Cheslack-Postava resolved KAFKA-5548.
------------------------------------------
       Resolution: Fixed
    Fix Version/s: 0.11.1.0

Issue resolved by pull request 3474
[https://github.com/apache/kafka/pull/3474]

> SchemaBuilder does not validate input.
> --------------------------------------
>
>                 Key: KAFKA-5548
>                 URL: https://issues.apache.org/jira/browse/KAFKA-5548
>             Project: Kafka
>          Issue Type: Bug
>          Components: KafkaConnect
>            Reporter: Jeremy Custenborder
>            Assignee: Jeremy Custenborder
>            Priority: Minor
>             Fix For: 0.11.1.0
>
>
> 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.
> {code:java}
>   @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();
>   }
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message