[ 
https://issues.apache.org/jira/browse/KAFKA-9192?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16979717#comment-16979717
 ] 

ASF GitHub Bot commented on KAFKA-9192:
---------------------------------------

levzem commented on pull request #7733: KAFKA-9192: fix NPE when for converting 
optional json schema in structs
URL: https://github.com/apache/kafka/pull/7733
 
 
   resolves the bug https://issues.apache.org/jira/browse/KAFKA-9192
   
   line #701 will throw a `NPE` if `jsonValue` is `null`, if the schema was 
optional and the field never existed
   
   Signed-off-by: Lev Zemlyanov <l...@confluent.io>
   
   ### Committer Checklist (excluded from commit message)
   - [ ] Verify design and implementation 
   - [ ] Verify test coverage and CI build status
   - [ ] Verify documentation (including upgrade notes)
   
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> NullPointerException if field in schema not present in value
> ------------------------------------------------------------
>
>                 Key: KAFKA-9192
>                 URL: https://issues.apache.org/jira/browse/KAFKA-9192
>             Project: Kafka
>          Issue Type: Bug
>          Components: KafkaConnect
>    Affects Versions: 2.2.1
>            Reporter: Mark Tinsley
>            Priority: Major
>
> Given a message:
> {code:java}
> {
>    "schema":{
>       "type":"struct",
>       "fields":[
>          {
>             "type":"string",
>             "optional":true,
>             "field":"abc"
>          }
>       ],
>       "optional":false,
>       "name":"foobar"
>    },
>    "payload":{
>    }
> }
> {code}
> I would expect, given the field is optional, for the JsonConverter to still 
> process this value. 
> What happens is I get a null pointer exception, the stacktrace points to this 
> line: 
> https://github.com/apache/kafka/blob/2.1/connect/json/src/main/java/org/apache/kafka/connect/json/JsonConverter.java#L701
>  called by 
> https://github.com/apache/kafka/blob/2.1/connect/json/src/main/java/org/apache/kafka/connect/json/JsonConverter.java#L181
> Issue seems to be that we need to check and see if the jsonValue is null 
> before checking if the jsonValue has a null value.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to