You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2017/07/01 01:25:00 UTC
[jira] [Commented] (KAFKA-5548) SchemaBuilder does not validate
input.
[ https://issues.apache.org/jira/browse/KAFKA-5548?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16070930#comment-16070930 ]
ASF GitHub Bot commented on KAFKA-5548:
---------------------------------------
GitHub user jcustenborder opened a pull request:
https://github.com/apache/kafka/pull/3474
KAFKA-5548 - Extended validation for SchemaBuilder methods.
More input validation for SchemaBuilder methods.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/jcustenborder/kafka KAFKA-5548
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/kafka/pull/3474.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #3474
----
commit 7389763d751ffdca963a4120c35cfd3328f1b414
Author: Jeremy Custenborder <jc...@gmail.com>
Date: 2017-07-01T01:17:57Z
KAFKA-5548 - Added test cases validating input for SchemaBuilder map(), array(), and field() methods. Changed methods to throw a SchemaBuilderException if nulls are passed into the SchemaBuilder map(), array(), and field() methods.
----
> 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
>
> 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)