You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Matthias J. Sax (JIRA)" <ji...@apache.org> on 2019/04/27 21:45:00 UTC

[jira] [Commented] (KAFKA-8296) Kafka Streams branch method raises type warnings

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

Matthias J. Sax commented on KAFKA-8296:
----------------------------------------

Not sure if KAFKA-5488 might actually remove `branch()` and replace with a different overload. Feel free to chime into the KIP discussion.

> Kafka Streams branch method raises type warnings
> ------------------------------------------------
>
>                 Key: KAFKA-8296
>                 URL: https://issues.apache.org/jira/browse/KAFKA-8296
>             Project: Kafka
>          Issue Type: Bug
>          Components: streams
>            Reporter: Michael Drogalis
>            Priority: Minor
>
> Because the branch method in the DSL takes vargargs, using it as follows raises an unchecked type warning:
> {code:java}
>         KStream<String, User>[] branches = builder.<String, User>stream(inputTopic)
>                 .branch((key, user) -> "united states".equals(user.getCountry()),
>                         (key, user) -> "germany".equals(user.getCountry()),
>                         (key, user) -> "mexico".equals(user.getCountry()),
>                         (key, user) -> true);
> {code}
> The compiler warns with:
> {code:java}
> Warning:(39, 24) java: unchecked generic array creation for varargs parameter of type org.apache.kafka.streams.kstream.Predicate<? super java.lang.String,? super io.confluent.developer.avro.User>[]
> {code}
> This is unfortunate because of the way Java's type system + generics work. We could possibly fix this by adding the @SafeVarargs annotation to the branch method signatures.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)