Kafka
  1. Kafka
  2. KAFKA-1146

toString() on KafkaStream gets stuck indefinitely

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: 0.8.0
    • Fix Version/s: 0.8.2.0
    • Component/s: consumer
    • Labels:

      Description

      There is no toString implementation for KafkaStream, so if a user tries to print the stream it falls back to default toString implementation which tries to iterate over the collection and gets stuck indefinitely as it awaits messages. KafkaStream could instead override the toString and return a verbose description of the stream with topic name etc.

      println("Current stream: " + stream) // This call never returns

      1. KAFKA-1146.patch
        0.5 kB
        Arup Malakar

        Activity

        Hide
        Jun Rao added a comment -

        Thanks for the patch. +1 and committed to trunk.

        Show
        Jun Rao added a comment - Thanks for the patch. +1 and committed to trunk.
        Hide
        Joel Koshy added a comment -

        We could just print something like "%s kafka stream".format(clientId) - there's very little information that the KafkaStream class exposes. However, this is more to protect against iterating over the full stream on a toString call. toString on KafkaStream does not really make sense - so even a message to that effect should be fine.

        Show
        Joel Koshy added a comment - We could just print something like "%s kafka stream".format(clientId) - there's very little information that the KafkaStream class exposes. However, this is more to protect against iterating over the full stream on a toString call. toString on KafkaStream does not really make sense - so even a message to that effect should be fine.
        Hide
        Arup Malakar added a comment -

        Joel Koshy Yes overriding would definitely be beneficial. I can submit a patch for this. Any suggestion on what I could put in the toString method?

        Show
        Arup Malakar added a comment - Joel Koshy Yes overriding would definitely be beneficial. I can submit a patch for this. Any suggestion on what I could put in the toString method?
        Hide
        Joel Koshy added a comment -

        Yes this is due to KafkaStream being a scala iterable - toString on
        an iterable (per the scala-doc): "returns a string representation of
        this collection. By default this string consists of the stringPrefix
        of this immutable iterable collection, followed by all elements
        separated by commas and enclosed in parentheses."
        We can just override it simce others have run into this as well.

        Show
        Joel Koshy added a comment - Yes this is due to KafkaStream being a scala iterable - toString on an iterable (per the scala-doc): "returns a string representation of this collection. By default this string consists of the stringPrefix of this immutable iterable collection, followed by all elements separated by commas and enclosed in parentheses." We can just override it simce others have run into this as well.

          People

          • Assignee:
            Arup Malakar
            Reporter:
            Arup Malakar
          • Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development