Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-7096

The ObjectHelper#createIterator utility should properly adhere the java.util.Iterator contract

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 2.12.2
    • 2.11.3, 2.12.3, 2.13.0
    • camel-core
    • None
    • Unknown

    Description

      According to the java.util.Iterator#next() contract the implementation should throw NoSuchElementException if the iteration has no more elements. However this is currently not the case by the different anonymous class implemetations of this interface through ObjectHelper#createIterator().

      The side effect of this is that currently this could end up with IndexOutOfBoundsException and what not if one would iterate over the Node(s) of a DOM NodeList. Another example is that calling next() on the Iterator returned for an empty String repeatedly doesn't throw any NoSuchElementException although it's hasNext() method returns false!

      We should better provide guards for the condition when there's no more elements available in which case a NoSuchElementException should be thrown.

      Attachments

        Activity

          People

            bvahdat Babak Vahdat
            bvahdat Babak Vahdat
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: