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

        Arup Malakar created issue -
        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.
        Joel Koshy made changes -
        Field Original Value New Value
        Fix Version/s 0.8.1 [ 12322960 ]
        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 -

        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.
        Jun Rao made changes -
        Labels newbie
        Assignee Neha Narkhede [ nehanarkhede ]
        Neha Narkhede made changes -
        Fix Version/s 0.9.0 [ 12323928 ]
        Fix Version/s 0.8.1 [ 12322960 ]
        Arup Malakar made changes -
        Status Open [ 1 ] Patch Available [ 10002 ]
        Arup Malakar made changes -
        Attachment KAFKA-1146.patch [ 12643003 ]
        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.
        Jun Rao made changes -
        Status Patch Available [ 10002 ] Resolved [ 5 ]
        Assignee Arup Malakar [ amalakar ]
        Fix Version/s 0.8.2 [ 12326167 ]
        Fix Version/s 0.9.0 [ 12323928 ]
        Resolution Fixed [ 1 ]
        Neha Narkhede made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Tony Stevenson made changes -
        Workflow no-reopen-closed, patch-avail [ 12828443 ] Apache Kafka Workflow [ 13051128 ]
        Tony Stevenson made changes -
        Workflow Apache Kafka Workflow [ 13051128 ] no-reopen-closed, patch-avail [ 13053537 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Patch Available Patch Available
        156d 11h 28m 1 Arup Malakar 02/May/14 06:31
        Patch Available Patch Available Resolved Resolved
        8h 15m 1 Jun Rao 02/May/14 14:46
        Resolved Resolved Closed Closed
        47d 14h 22m 1 Neha Narkhede 19/Jun/14 05:09

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development