[ https://issues.apache.org/jira/browse/KAFKA-10036?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17119257#comment-17119257 ]
Alex Sun commented on KAFKA-10036: ---------------------------------- Simplified version is: Multiple ProcessorContext tried to register in a same processor instance, but processor instance could only have one ProcessorContext to callback. So the StreamThread who owns each ProcessorContext dispatch record to instance and callback somewhere else(not its thread local ProcessorContext). And it led to inconsistency. > Improve error message if user violates `Supplier` pattern > --------------------------------------------------------- > > Key: KAFKA-10036 > URL: https://issues.apache.org/jira/browse/KAFKA-10036 > Project: Kafka > Issue Type: Improvement > Components: streams > Reporter: Matthias J. Sax > Assignee: Alex Sun > Priority: Minor > Labels: newbie > > Using the Processor API, users need to pass in a `ProcessorSupplier` that > needs to return new `Processor` instance each time `get()` is called. > Users violate this rule on a regular basis and return the same instance on > `get()`. This mistake leads to a (not very informative) > `NullPointerException` during runtime. (Cf: > [https://stackoverflow.com/questions/61790984/kafka-stream-forward-method-throwing-nullpointerexception-because-processornode/61978396)] > We could improve the error message by checking if `currentNode()` returns > `null` > ([https://github.com/apache/kafka/blob/2.4/streams/src/main/java/org/apache/kafka/streams/processor/internals/ProcessorContextImpl.java#L183)] > and throw an informative error message for this case. > Furthermore, we could do a "sanity" check within `KafkaStreams` constructor > before we start the process threads: we get all `Suppliers` for the > `Topology` and call `get()` two times on each supplier to compare if the > returned object references are different – if they are the same, we throw an > informative error message. > We should improve the JavaDocs, too: > [https://github.com/apache/kafka/blob/2.4/streams/src/main/java/org/apache/kafka/streams/processor/ProcessorSupplier.java#L34] > (also for `Transformer` et al. – it seems to be too subtle what "new" means. > Similarly for > [https://github.com/apache/kafka/blob/2.4/streams/src/main/java/org/apache/kafka/streams/Topology.java] > and > [https://github.com/apache/kafka/blob/2.4/streams/src/main/java/org/apache/kafka/streams/kstream/KStream.java] > (`process()`, `transform()` etc.) > Furthermore, we should improve the docs: to explain the supplier pattern > explicitly: > [https://kafka.apache.org/25/documentation/streams/developer-guide/processor-api.html] -- This message was sent by Atlassian Jira (v8.3.4#803005)