You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Romain Quinio (Jira)" <ji...@apache.org> on 2022/07/08 09:53:00 UTC

[jira] [Comment Edited] (KAFKA-9109) Get Rid of Cast from ProcessorContext to InternalProcessorContext

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

Romain Quinio edited comment on KAFKA-9109 at 7/8/22 9:52 AM:
--------------------------------------------------------------

I've faced the same issue when upgrading a library to new Kafka3 PAPI, very annoying.

In order to support both old and new APIs via the ProcessorAdapter, our decorators of org.apache.kafka.streams.processor.api.ProcessorContext must actually implement InternalProcessorContext (by extending org.apache.kafka.streams.processor.internals.ProcessorContextImpl) to workaround the cast done at https://github.com/apache/kafka/blob/63a6130af30536d67fca5802005695a84c875b5e/streams/src/main/java/org/apache/kafka/streams/processor/internals/ProcessorAdapter.java#L56


was (Author: rquinio):
I've faced the same issue when upgrading a library to new PAPI, very annoying.

In order to support both old and new APIs, our decorators of org.apache.kafka.streams.processor.api.ProcessorContext must actually implement InternalProcessorContext (by extending org.apache.kafka.streams.processor.internals.ProcessorContextImpl) to workaround the cast...

> Get Rid of Cast from ProcessorContext to InternalProcessorContext
> -----------------------------------------------------------------
>
>                 Key: KAFKA-9109
>                 URL: https://issues.apache.org/jira/browse/KAFKA-9109
>             Project: Kafka
>          Issue Type: Improvement
>          Components: streams
>            Reporter: Bruno Cadonna
>            Priority: Major
>
> The following cast is often used in Kafka Streams code.
> {code:java}
> public void init(final ProcessorContext context) {
>     internalProcessorContext = (InternalProcessorContext) context;
>     ...
> }
> {code}
> This code leads to a {{ClassCastException}} if the implementation of the {{ProcessorContext}} is not an {{InternalProcessorContext}}, which defeats the purpose of using interface {{ProcessorContext}} in the API.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)