Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-8296

Kafka Streams branch method raises type warnings

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Duplicate
    • None
    • None
    • streams
    • None

    Description

      Because the branch method in the DSL takes vargargs, using it as follows raises an unchecked type warning:

              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);
      

      The compiler warns with:

      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>[]
      

      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.

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            iponomarev Ivan Ponomarev
            mdrogalis Michael Drogalis
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment