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

Randall Hauch commented on KAFKA-7052:
--------------------------------------

On second though, I'm not sure we can change the behavior without risking 
backward-incompatible changes.

First, the current behavior when the SMT can't be applied is to fail with an 
NPE. We try to use meaningful exceptions with useful error messages, and the 
lack of any code to check for this situation likely means this case was simply 
not considered and throwing an NPE is unintentional. This is an argument for 
changing the behavior to skip any record for which the specified field is not 
found.

Second, it's probably not practical for users to rely upon this existing NPE 
behavior when used with a +source+ connector, since that would leave the 
connector in a failed state without advancing offsets. Essentially, the 
connector would be stuck and unable to continue unless the configuration is 
changed.

However, if someone were to use this SMT with a +sink+ connector and use the 
DLQ functionality, they might be relying upon the NPE to signal that the record 
should go to the DLQ. If we were to change the behavior, the record would no 
longer go to the DLQ and instead would get sent to any subsequent 
transformation and ultimately to the sink connector.

Therefore, changing to have the SMT skip any record for which the field is not 
found is technically not a backward compatible change, and this would require a 
KIP or, better yet, require introducing a new configuration property (as 
mentioned in my previous comment) that would default to "fail" to maintain 
backward compatibility.

Thoughts?

 

> ExtractField SMT throws NPE - needs clearer error message
> ---------------------------------------------------------
>
>                 Key: KAFKA-7052
>                 URL: https://issues.apache.org/jira/browse/KAFKA-7052
>             Project: Kafka
>          Issue Type: Improvement
>          Components: KafkaConnect
>            Reporter: Robin Moffatt
>            Priority: Major
>
> With the following Single Message Transform: 
> {code:java}
> "transforms.ExtractId.type":"org.apache.kafka.connect.transforms.ExtractField$Key",
> "transforms.ExtractId.field":"id"{code}
> Kafka Connect errors with : 
> {code:java}
> java.lang.NullPointerException
> at 
> org.apache.kafka.connect.transforms.ExtractField.apply(ExtractField.java:61)
> at 
> org.apache.kafka.connect.runtime.TransformationChain.apply(TransformationChain.java:38){code}
> There should be a better error message here, identifying the reason for the 
> NPE.
> Version: Confluent Platform 4.1.1



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

Reply via email to