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

ConsumerRecords iterator throws NoSuchElementException when a TopicPartition is empty

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 0.9.0.0, 0.9.0.1
    • Fix Version/s: 0.10.0.0
    • Component/s: clients, consumer
    • Labels:

      Description

      The makeNext method in the private static ConcatenatedIterable class of ConsumerRecords assumes that each TopicPartition is non-empty. When this is not the case we get a NoSuchElementException when getting the next element (see the ConsumerRecordsTest class I created):

      java.util.NoSuchElementException
      	at java.util.ArrayList$Itr.next(ArrayList.java:854)
      	at org.apache.kafka.clients.consumer.ConsumerRecords$ConcatenatedIterable$1.makeNext(ConsumerRecords.java:110)
      	at org.apache.kafka.clients.consumer.ConsumerRecords$ConcatenatedIterable$1.makeNext(ConsumerRecords.java:99)
      	at org.apache.kafka.common.utils.AbstractIterator.maybeComputeNext(AbstractIterator.java:79)
      	at org.apache.kafka.common.utils.AbstractIterator.hasNext(AbstractIterator.java:45)
      	at org.apache.kafka.clients.consumer.ConsumerRecordsTest.iterator(ConsumerRecordsTest.java:53)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:497)
      	at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:68)
      	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:310)
      	at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:89)
      	at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:97)
      	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.executeTest(PowerMockJUnit44RunnerDelegateImpl.java:294)
      	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTestInSuper(PowerMockJUnit47RunnerDelegateImpl.java:127)
      	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTest(PowerMockJUnit47RunnerDelegateImpl.java:82)
      	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runBeforesThenTestThenAfters(PowerMockJUnit44RunnerDelegateImpl.java:282)
      	at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:87)
      	at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:50)
      	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.invokeTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:207)
      	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.runMethods(PowerMockJUnit44RunnerDelegateImpl.java:146)
      	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$1.run(PowerMockJUnit44RunnerDelegateImpl.java:120)
      	at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:34)
      	at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:44)
      	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.run(PowerMockJUnit44RunnerDelegateImpl.java:122)
      	at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run(JUnit4TestSuiteChunkerImpl.java:106)
      	at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.run(AbstractCommonPowerMockRunner.java:53)
      	at org.powermock.modules.junit4.PowerMockRunner.run(PowerMockRunner.java:59)
      	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
      	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:119)
      	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
      	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
      	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:497)
      	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
      

      I'm pretty new to Kafka, so there may be some context I'm missing here, but this seems like a pretty straightforward bug to me.

        Attachments

          Activity

            People

            • Assignee:
              daedalus2718 Drausin Wulsin
              Reporter:
              daedalus2718 Drausin Wulsin
              Reviewer:
              Jay Kreps
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: