[jira] [Commented] (KAFKA-4183) Logical converters in JsonConverter don't properly handle null values
[ https://issues.apache.org/jira/browse/KAFKA-4183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15504479#comment-15504479 ] ASF GitHub Bot commented on KAFKA-4183: --- Github user asfgit closed the pull request at: https://github.com/apache/kafka/pull/1872 > Logical converters in JsonConverter don't properly handle null values > - > > Key: KAFKA-4183 > URL: https://issues.apache.org/jira/browse/KAFKA-4183 > Project: Kafka > Issue Type: Bug > Components: KafkaConnect >Affects Versions: 0.10.0.1 >Reporter: Randall Hauch >Assignee: Shikhar Bhushan > Fix For: 0.10.1.0 > > > The {{JsonConverter.TO_CONNECT_LOGICAL_CONVERTERS}} map contains > {{LogicalTypeConverter}} implementations to convert from the raw value into > the corresponding logical type value, and they are used during > deserialization of message keys and/or values. However, these implementations > do not handle the case when the input raw value is null, which can happen > when a key or value has a schema that is or contains a field that is > _optional_. > Consider a Kafka Connect schema of type STRUCT that contains a field "date" > with an optional schema of type {{org.apache.kafka.connect.data.Date}}. When > the key or value with this schema contains a null "date" field and is > serialized, the logical serializer properly will serialize the null value. > However, upon _deserialization_, the > {{JsonConverter.TO_CONNECT_LOGICAL_CONVERTERS}} are used to convert the > literal value (which is null) to a logical value. All of the > {{JsonConverter.TO_CONNECT_LOGICAL_CONVERTERS}} implementations will throw a > NullPointerException when the input value is null. > For example: > {code:java} > java.lang.NullPointerException > at > org.apache.kafka.connect.json.JsonConverter$14.convert(JsonConverter.java:224) > at > org.apache.kafka.connect.json.JsonConverter.convertToConnect(JsonConverter.java:731) > at > org.apache.kafka.connect.json.JsonConverter.access$100(JsonConverter.java:53) > at > org.apache.kafka.connect.json.JsonConverter$12.convert(JsonConverter.java:200) > at > org.apache.kafka.connect.json.JsonConverter.convertToConnect(JsonConverter.java:727) > at > org.apache.kafka.connect.json.JsonConverter.jsonToConnect(JsonConverter.java:354) > at > org.apache.kafka.connect.json.JsonConverter.toConnectData(JsonConverter.java:343) > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (KAFKA-4183) Logical converters in JsonConverter don't properly handle null values
[ https://issues.apache.org/jira/browse/KAFKA-4183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15497716#comment-15497716 ] ASF GitHub Bot commented on KAFKA-4183: --- GitHub user shikhar opened a pull request: https://github.com/apache/kafka/pull/1872 KAFKA-4183: centralize checking for optional and default values to avoid bugs Cleaner to just check once for optional & default value from the `convertToConnect()` function. It also helps address an issue with conversions for logical type schemas that have default values and null as the included value. That test case is _probably_ not an issue in practice, since when using the `JsonConverter` to serialize a missing field with a default value, it will serialize the default value for the field. But in the face of JSON data streaming in from a topic being [generous on input, strict on output](http://tedwise.com/2009/05/27/generous-on-input-strict-on-output) seems best. You can merge this pull request into a Git repository by running: $ git pull https://github.com/shikhar/kafka kafka-4183 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/kafka/pull/1872.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 #1872 commit 1e09c6431f11361e7f3a5af4c09a8174c3547669 Author: Shikhar BhushanDate: 2016-09-16T23:17:40Z KAFKA-4183: centralize checking for optional and default values to avoid bugs > Logical converters in JsonConverter don't properly handle null values > - > > Key: KAFKA-4183 > URL: https://issues.apache.org/jira/browse/KAFKA-4183 > Project: Kafka > Issue Type: Bug > Components: KafkaConnect >Affects Versions: 0.10.0.1 >Reporter: Randall Hauch >Assignee: Shikhar Bhushan > Fix For: 0.10.1.0 > > > The {{JsonConverter.TO_CONNECT_LOGICAL_CONVERTERS}} map contains > {{LogicalTypeConverter}} implementations to convert from the raw value into > the corresponding logical type value, and they are used during > deserialization of message keys and/or values. However, these implementations > do not handle the case when the input raw value is null, which can happen > when a key or value has a schema that is or contains a field that is > _optional_. > Consider a Kafka Connect schema of type STRUCT that contains a field "date" > with an optional schema of type {{org.apache.kafka.connect.data.Date}}. When > the key or value with this schema contains a null "date" field and is > serialized, the logical serializer properly will serialize the null value. > However, upon _deserialization_, the > {{JsonConverter.TO_CONNECT_LOGICAL_CONVERTERS}} are used to convert the > literal value (which is null) to a logical value. All of the > {{JsonConverter.TO_CONNECT_LOGICAL_CONVERTERS}} implementations will throw a > NullPointerException when the input value is null. > For example: > {code:java} > java.lang.NullPointerException > at > org.apache.kafka.connect.json.JsonConverter$14.convert(JsonConverter.java:224) > at > org.apache.kafka.connect.json.JsonConverter.convertToConnect(JsonConverter.java:731) > at > org.apache.kafka.connect.json.JsonConverter.access$100(JsonConverter.java:53) > at > org.apache.kafka.connect.json.JsonConverter$12.convert(JsonConverter.java:200) > at > org.apache.kafka.connect.json.JsonConverter.convertToConnect(JsonConverter.java:727) > at > org.apache.kafka.connect.json.JsonConverter.jsonToConnect(JsonConverter.java:354) > at > org.apache.kafka.connect.json.JsonConverter.toConnectData(JsonConverter.java:343) > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (KAFKA-4183) Logical converters in JsonConverter don't properly handle null values
[ https://issues.apache.org/jira/browse/KAFKA-4183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15497694#comment-15497694 ] Randall Hauch commented on KAFKA-4183: -- [~shikhar], that'd be great. Note that I created two PRs: one for {{trunk}} and one for {{0.10.0}}. > Logical converters in JsonConverter don't properly handle null values > - > > Key: KAFKA-4183 > URL: https://issues.apache.org/jira/browse/KAFKA-4183 > Project: Kafka > Issue Type: Bug > Components: KafkaConnect >Affects Versions: 0.10.0.1 >Reporter: Randall Hauch >Assignee: Shikhar Bhushan > Fix For: 0.10.1.0 > > > The {{JsonConverter.TO_CONNECT_LOGICAL_CONVERTERS}} map contains > {{LogicalTypeConverter}} implementations to convert from the raw value into > the corresponding logical type value, and they are used during > deserialization of message keys and/or values. However, these implementations > do not handle the case when the input raw value is null, which can happen > when a key or value has a schema that is or contains a field that is > _optional_. > Consider a Kafka Connect schema of type STRUCT that contains a field "date" > with an optional schema of type {{org.apache.kafka.connect.data.Date}}. When > the key or value with this schema contains a null "date" field and is > serialized, the logical serializer properly will serialize the null value. > However, upon _deserialization_, the > {{JsonConverter.TO_CONNECT_LOGICAL_CONVERTERS}} are used to convert the > literal value (which is null) to a logical value. All of the > {{JsonConverter.TO_CONNECT_LOGICAL_CONVERTERS}} implementations will throw a > NullPointerException when the input value is null. > For example: > {code:java} > java.lang.NullPointerException > at > org.apache.kafka.connect.json.JsonConverter$14.convert(JsonConverter.java:224) > at > org.apache.kafka.connect.json.JsonConverter.convertToConnect(JsonConverter.java:731) > at > org.apache.kafka.connect.json.JsonConverter.access$100(JsonConverter.java:53) > at > org.apache.kafka.connect.json.JsonConverter$12.convert(JsonConverter.java:200) > at > org.apache.kafka.connect.json.JsonConverter.convertToConnect(JsonConverter.java:727) > at > org.apache.kafka.connect.json.JsonConverter.jsonToConnect(JsonConverter.java:354) > at > org.apache.kafka.connect.json.JsonConverter.toConnectData(JsonConverter.java:343) > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (KAFKA-4183) Logical converters in JsonConverter don't properly handle null values
[ https://issues.apache.org/jira/browse/KAFKA-4183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15497626#comment-15497626 ] Randall Hauch commented on KAFKA-4183: -- [~hachikuji], thanks. I've created a [pull request|https://github.com/apache/kafka/pull/1871] for the {{0.10.0}} branch. > Logical converters in JsonConverter don't properly handle null values > - > > Key: KAFKA-4183 > URL: https://issues.apache.org/jira/browse/KAFKA-4183 > Project: Kafka > Issue Type: Bug > Components: KafkaConnect >Affects Versions: 0.10.0.1 >Reporter: Randall Hauch >Assignee: Ewen Cheslack-Postava > Fix For: 0.10.1.0 > > > The {{JsonConverter.TO_CONNECT_LOGICAL_CONVERTERS}} map contains > {{LogicalTypeConverter}} implementations to convert from the raw value into > the corresponding logical type value, and they are used during > deserialization of message keys and/or values. However, these implementations > do not handle the case when the input raw value is null, which can happen > when a key or value has a schema that is or contains a field that is > _optional_. > Consider a Kafka Connect schema of type STRUCT that contains a field "date" > with an optional schema of type {{org.apache.kafka.connect.data.Date}}. When > the key or value with this schema contains a null "date" field and is > serialized, the logical serializer properly will serialize the null value. > However, upon _deserialization_, the > {{JsonConverter.TO_CONNECT_LOGICAL_CONVERTERS}} are used to convert the > literal value (which is null) to a logical value. All of the > {{JsonConverter.TO_CONNECT_LOGICAL_CONVERTERS}} implementations will throw a > NullPointerException when the input value is null. > For example: > {code:java} > java.lang.NullPointerException > at > org.apache.kafka.connect.json.JsonConverter$14.convert(JsonConverter.java:224) > at > org.apache.kafka.connect.json.JsonConverter.convertToConnect(JsonConverter.java:731) > at > org.apache.kafka.connect.json.JsonConverter.access$100(JsonConverter.java:53) > at > org.apache.kafka.connect.json.JsonConverter$12.convert(JsonConverter.java:200) > at > org.apache.kafka.connect.json.JsonConverter.convertToConnect(JsonConverter.java:727) > at > org.apache.kafka.connect.json.JsonConverter.jsonToConnect(JsonConverter.java:354) > at > org.apache.kafka.connect.json.JsonConverter.toConnectData(JsonConverter.java:343) > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (KAFKA-4183) Logical converters in JsonConverter don't properly handle null values
[ https://issues.apache.org/jira/browse/KAFKA-4183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15497623#comment-15497623 ] ASF GitHub Bot commented on KAFKA-4183: --- GitHub user rhauch opened a pull request: https://github.com/apache/kafka/pull/1871 KAFKA-4183 Corrected Kafka Connect's JSON Converter to properly convert from null to logical values The `JsonConverter` class has `LogicalTypeConverter` implementations for Date, Time, Timestamp, and Decimal, but these implementations fail when the input literal value (deserialized from the message) is null. Test cases were added to check for these cases, and these failed before the `LogicalTypeConverter` implementations were fixed to consider whether the schema has a default value or is optional, similarly to how the `JsonToConnectTypeConverter` implementations do this. Once the fixes were made, the new tests pass. You can merge this pull request into a Git repository by running: $ git pull https://github.com/rhauch/kafka kafka-4183-0.10.0 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/kafka/pull/1871.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 #1871 commit 4ffb9409f5a75345cf53aed0d799e6c694f636ca Author: Randall HauchDate: 2016-09-16T19:05:06Z KAFKA-4183 Corrected Kafka Connect's JSON Converter to properly convert from deserialized null values. > Logical converters in JsonConverter don't properly handle null values > - > > Key: KAFKA-4183 > URL: https://issues.apache.org/jira/browse/KAFKA-4183 > Project: Kafka > Issue Type: Bug > Components: KafkaConnect >Affects Versions: 0.10.0.1 >Reporter: Randall Hauch >Assignee: Ewen Cheslack-Postava > Fix For: 0.10.1.0 > > > The {{JsonConverter.TO_CONNECT_LOGICAL_CONVERTERS}} map contains > {{LogicalTypeConverter}} implementations to convert from the raw value into > the corresponding logical type value, and they are used during > deserialization of message keys and/or values. However, these implementations > do not handle the case when the input raw value is null, which can happen > when a key or value has a schema that is or contains a field that is > _optional_. > Consider a Kafka Connect schema of type STRUCT that contains a field "date" > with an optional schema of type {{org.apache.kafka.connect.data.Date}}. When > the key or value with this schema contains a null "date" field and is > serialized, the logical serializer properly will serialize the null value. > However, upon _deserialization_, the > {{JsonConverter.TO_CONNECT_LOGICAL_CONVERTERS}} are used to convert the > literal value (which is null) to a logical value. All of the > {{JsonConverter.TO_CONNECT_LOGICAL_CONVERTERS}} implementations will throw a > NullPointerException when the input value is null. > For example: > {code:java} > java.lang.NullPointerException > at > org.apache.kafka.connect.json.JsonConverter$14.convert(JsonConverter.java:224) > at > org.apache.kafka.connect.json.JsonConverter.convertToConnect(JsonConverter.java:731) > at > org.apache.kafka.connect.json.JsonConverter.access$100(JsonConverter.java:53) > at > org.apache.kafka.connect.json.JsonConverter$12.convert(JsonConverter.java:200) > at > org.apache.kafka.connect.json.JsonConverter.convertToConnect(JsonConverter.java:727) > at > org.apache.kafka.connect.json.JsonConverter.jsonToConnect(JsonConverter.java:354) > at > org.apache.kafka.connect.json.JsonConverter.toConnectData(JsonConverter.java:343) > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (KAFKA-4183) Logical converters in JsonConverter don't properly handle null values
[ https://issues.apache.org/jira/browse/KAFKA-4183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15497578#comment-15497578 ] Jason Gustafson commented on KAFKA-4183: [~rhauch] Good question. I'm not sure I have the answer, but if you open a PR into 0.10.0, I'll merge it there. > Logical converters in JsonConverter don't properly handle null values > - > > Key: KAFKA-4183 > URL: https://issues.apache.org/jira/browse/KAFKA-4183 > Project: Kafka > Issue Type: Bug > Components: KafkaConnect >Affects Versions: 0.10.0.1 >Reporter: Randall Hauch >Assignee: Ewen Cheslack-Postava > Fix For: 0.10.1.0 > > > The {{JsonConverter.TO_CONNECT_LOGICAL_CONVERTERS}} map contains > {{LogicalTypeConverter}} implementations to convert from the raw value into > the corresponding logical type value, and they are used during > deserialization of message keys and/or values. However, these implementations > do not handle the case when the input raw value is null, which can happen > when a key or value has a schema that is or contains a field that is > _optional_. > Consider a Kafka Connect schema of type STRUCT that contains a field "date" > with an optional schema of type {{org.apache.kafka.connect.data.Date}}. When > the key or value with this schema contains a null "date" field and is > serialized, the logical serializer properly will serialize the null value. > However, upon _deserialization_, the > {{JsonConverter.TO_CONNECT_LOGICAL_CONVERTERS}} are used to convert the > literal value (which is null) to a logical value. All of the > {{JsonConverter.TO_CONNECT_LOGICAL_CONVERTERS}} implementations will throw a > NullPointerException when the input value is null. > For example: > {code:java} > java.lang.NullPointerException > at > org.apache.kafka.connect.json.JsonConverter$14.convert(JsonConverter.java:224) > at > org.apache.kafka.connect.json.JsonConverter.convertToConnect(JsonConverter.java:731) > at > org.apache.kafka.connect.json.JsonConverter.access$100(JsonConverter.java:53) > at > org.apache.kafka.connect.json.JsonConverter$12.convert(JsonConverter.java:200) > at > org.apache.kafka.connect.json.JsonConverter.convertToConnect(JsonConverter.java:727) > at > org.apache.kafka.connect.json.JsonConverter.jsonToConnect(JsonConverter.java:354) > at > org.apache.kafka.connect.json.JsonConverter.toConnectData(JsonConverter.java:343) > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (KAFKA-4183) Logical converters in JsonConverter don't properly handle null values
[ https://issues.apache.org/jira/browse/KAFKA-4183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15497530#comment-15497530 ] Randall Hauch commented on KAFKA-4183: -- [~hachikuji], will there be a 0.10.0.2? If so, any chance this might be included? > Logical converters in JsonConverter don't properly handle null values > - > > Key: KAFKA-4183 > URL: https://issues.apache.org/jira/browse/KAFKA-4183 > Project: Kafka > Issue Type: Bug > Components: KafkaConnect >Affects Versions: 0.10.0.1 >Reporter: Randall Hauch >Assignee: Ewen Cheslack-Postava > Fix For: 0.10.1.0 > > > The {{JsonConverter.TO_CONNECT_LOGICAL_CONVERTERS}} map contains > {{LogicalTypeConverter}} implementations to convert from the raw value into > the corresponding logical type value, and they are used during > deserialization of message keys and/or values. However, these implementations > do not handle the case when the input raw value is null, which can happen > when a key or value has a schema that is or contains a field that is > _optional_. > Consider a Kafka Connect schema of type STRUCT that contains a field "date" > with an optional schema of type {{org.apache.kafka.connect.data.Date}}. When > the key or value with this schema contains a null "date" field and is > serialized, the logical serializer properly will serialize the null value. > However, upon _deserialization_, the > {{JsonConverter.TO_CONNECT_LOGICAL_CONVERTERS}} are used to convert the > literal value (which is null) to a logical value. All of the > {{JsonConverter.TO_CONNECT_LOGICAL_CONVERTERS}} implementations will throw a > NullPointerException when the input value is null. > For example: > {code:java} > java.lang.NullPointerException > at > org.apache.kafka.connect.json.JsonConverter$14.convert(JsonConverter.java:224) > at > org.apache.kafka.connect.json.JsonConverter.convertToConnect(JsonConverter.java:731) > at > org.apache.kafka.connect.json.JsonConverter.access$100(JsonConverter.java:53) > at > org.apache.kafka.connect.json.JsonConverter$12.convert(JsonConverter.java:200) > at > org.apache.kafka.connect.json.JsonConverter.convertToConnect(JsonConverter.java:727) > at > org.apache.kafka.connect.json.JsonConverter.jsonToConnect(JsonConverter.java:354) > at > org.apache.kafka.connect.json.JsonConverter.toConnectData(JsonConverter.java:343) > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (KAFKA-4183) Logical converters in JsonConverter don't properly handle null values
[ https://issues.apache.org/jira/browse/KAFKA-4183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15497511#comment-15497511 ] ASF GitHub Bot commented on KAFKA-4183: --- Github user asfgit closed the pull request at: https://github.com/apache/kafka/pull/1867 > Logical converters in JsonConverter don't properly handle null values > - > > Key: KAFKA-4183 > URL: https://issues.apache.org/jira/browse/KAFKA-4183 > Project: Kafka > Issue Type: Bug > Components: KafkaConnect >Affects Versions: 0.10.0.1 >Reporter: Randall Hauch >Assignee: Ewen Cheslack-Postava > Fix For: 0.10.1.0 > > > The {{JsonConverter.TO_CONNECT_LOGICAL_CONVERTERS}} map contains > {{LogicalTypeConverter}} implementations to convert from the raw value into > the corresponding logical type value, and they are used during > deserialization of message keys and/or values. However, these implementations > do not handle the case when the input raw value is null, which can happen > when a key or value has a schema that is or contains a field that is > _optional_. > Consider a Kafka Connect schema of type STRUCT that contains a field "date" > with an optional schema of type {{org.apache.kafka.connect.data.Date}}. When > the key or value with this schema contains a null "date" field and is > serialized, the logical serializer properly will serialize the null value. > However, upon _deserialization_, the > {{JsonConverter.TO_CONNECT_LOGICAL_CONVERTERS}} are used to convert the > literal value (which is null) to a logical value. All of the > {{JsonConverter.TO_CONNECT_LOGICAL_CONVERTERS}} implementations will throw a > NullPointerException when the input value is null. > For example: > {code:java} > java.lang.NullPointerException > at > org.apache.kafka.connect.json.JsonConverter$14.convert(JsonConverter.java:224) > at > org.apache.kafka.connect.json.JsonConverter.convertToConnect(JsonConverter.java:731) > at > org.apache.kafka.connect.json.JsonConverter.access$100(JsonConverter.java:53) > at > org.apache.kafka.connect.json.JsonConverter$12.convert(JsonConverter.java:200) > at > org.apache.kafka.connect.json.JsonConverter.convertToConnect(JsonConverter.java:727) > at > org.apache.kafka.connect.json.JsonConverter.jsonToConnect(JsonConverter.java:354) > at > org.apache.kafka.connect.json.JsonConverter.toConnectData(JsonConverter.java:343) > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (KAFKA-4183) Logical converters in JsonConverter don't properly handle null values
[ https://issues.apache.org/jira/browse/KAFKA-4183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15497133#comment-15497133 ] ASF GitHub Bot commented on KAFKA-4183: --- GitHub user rhauch opened a pull request: https://github.com/apache/kafka/pull/1867 KAFKA-4183 Corrected Kafka Connect's JSON Converter to properly convert from null to logical values The `JsonConverter` class has `LogicalTypeConverter` implementations for Date, Time, Timestamp, and Decimal, but these implementations fail when the input literal value (deserialized from the message) is null. Test cases were added to check for these cases, and these failed before the `LogicalTypeConverter` implementations were fixed to consider whether the schema has a default value or is optional, similarly to how the `JsonToConnectTypeConverter` implementations do this. Once the fixes were made, the new tests pass. You can merge this pull request into a Git repository by running: $ git pull https://github.com/rhauch/kafka kafka-4183 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/kafka/pull/1867.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 #1867 commit c21db21e7b56f7c8ea31fab9852a6852dc038015 Author: Randall HauchDate: 2016-09-16T19:05:06Z KAFKA-4183 Corrected Kafka Connect's JSON Converter to properly convert from deserialized null values. > Logical converters in JsonConverter don't properly handle null values > - > > Key: KAFKA-4183 > URL: https://issues.apache.org/jira/browse/KAFKA-4183 > Project: Kafka > Issue Type: Bug > Components: KafkaConnect >Affects Versions: 0.10.0.1 >Reporter: Randall Hauch >Assignee: Ewen Cheslack-Postava > > The {{JsonConverter.TO_CONNECT_LOGICAL_CONVERTERS}} map contains > {{LogicalTypeConverter}} implementations to convert from the raw value into > the corresponding logical type value, and they are used during > deserialization of message keys and/or values. However, these implementations > do not handle the case when the input raw value is null, which can happen > when a key or value has a schema that is or contains a field that is > _optional_. > Consider a Kafka Connect schema of type STRUCT that contains a field "date" > with an optional schema of type {{org.apache.kafka.connect.data.Date}}. When > the key or value with this schema contains a null "date" field and is > serialized, the logical serializer properly will serialize the null value. > However, upon _deserialization_, the > {{JsonConverter.TO_CONNECT_LOGICAL_CONVERTERS}} are used to convert the > literal value (which is null) to a logical value. All of the > {{JsonConverter.TO_CONNECT_LOGICAL_CONVERTERS}} implementations will throw a > NullPointerException when the input value is null. > For example: > {code:java} > java.lang.NullPointerException > at > org.apache.kafka.connect.json.JsonConverter$14.convert(JsonConverter.java:224) > at > org.apache.kafka.connect.json.JsonConverter.convertToConnect(JsonConverter.java:731) > at > org.apache.kafka.connect.json.JsonConverter.access$100(JsonConverter.java:53) > at > org.apache.kafka.connect.json.JsonConverter$12.convert(JsonConverter.java:200) > at > org.apache.kafka.connect.json.JsonConverter.convertToConnect(JsonConverter.java:727) > at > org.apache.kafka.connect.json.JsonConverter.jsonToConnect(JsonConverter.java:354) > at > org.apache.kafka.connect.json.JsonConverter.toConnectData(JsonConverter.java:343) > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (KAFKA-4183) Logical converters in JsonConverter don't properly handle null values
[ https://issues.apache.org/jira/browse/KAFKA-4183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15497073#comment-15497073 ] Randall Hauch commented on KAFKA-4183: -- I should be able to provide a pull request to fix this. I guess I'll do it against "trunk" (for 0.10.1.0?), even though I'd love for this fix to be backported to any upcoming 0.10.0.x release. > Logical converters in JsonConverter don't properly handle null values > - > > Key: KAFKA-4183 > URL: https://issues.apache.org/jira/browse/KAFKA-4183 > Project: Kafka > Issue Type: Bug > Components: KafkaConnect >Affects Versions: 0.10.0.1 >Reporter: Randall Hauch >Assignee: Ewen Cheslack-Postava > > The {{JsonConverter.TO_CONNECT_LOGICAL_CONVERTERS}} map contains > {{LogicalTypeConverter}} implementations to convert from the raw value into > the corresponding logical type value, and they are used during > deserialization of message keys and/or values. However, these implementations > do not handle the case when the input raw value is null, which can happen > when a key or value has a schema that is or contains a field that is > _optional_. > Consider a Kafka Connect schema of type STRUCT that contains a field "date" > with an optional schema of type {{org.apache.kafka.connect.data.Date}}. When > the key or value with this schema contains a null "date" field and is > serialized, the logical serializer properly will serialize the null value. > However, upon _deserialization_, the > {{JsonConverter.TO_CONNECT_LOGICAL_CONVERTERS}} are used to convert the > literal value (which is null) to a logical value. All of the > {{JsonConverter.TO_CONNECT_LOGICAL_CONVERTERS}} implementations will throw a > NullPointerException when the input value is null. > For example: > {code:java} > java.lang.NullPointerException > at > org.apache.kafka.connect.json.JsonConverter$14.convert(JsonConverter.java:224) > at > org.apache.kafka.connect.json.JsonConverter.convertToConnect(JsonConverter.java:731) > at > org.apache.kafka.connect.json.JsonConverter.access$100(JsonConverter.java:53) > at > org.apache.kafka.connect.json.JsonConverter$12.convert(JsonConverter.java:200) > at > org.apache.kafka.connect.json.JsonConverter.convertToConnect(JsonConverter.java:727) > at > org.apache.kafka.connect.json.JsonConverter.jsonToConnect(JsonConverter.java:354) > at > org.apache.kafka.connect.json.JsonConverter.toConnectData(JsonConverter.java:343) > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)