Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-6165

Inconsistent behavior of Markupstream.hasMore vs. MarkupStream.next.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 7.3.0
    • 6.27.0, 7.7.0, 8.0.0-M4
    • wicket
    • None

    Description

      hasMore: return currentIndex < markup.size();
      next:    if (++currentIndex < markup.size()) {...}
      me:      while (markupStream.hasMore()) {...}
      

      I get a null element within the while loop which I wouldn't expect to get. markup.size() is 73, currentIndex 72, so "hasMore" returns true, while "next" returns null, because it already advanced the index during its check. "hasMore" saying "yes" while "next" saying "no" seems inconsistent to me, even though one can check the return value of "next" against "null".

      Shouldn't "next" use

      if (currentIndex++ < markup.size()) {...}
      

      to be in line with "hasMore"? Or more better directly call "hasMore" for the check itself to have only one single consistent implementation of the check?

      Attachments

        1. MarkupStream.java.patch
          4 kB
          Thorsten Schöning
        2. MarkupStream.java.patch
          8 kB
          Thorsten Schöning
        3. HtmlHandler.java.patch
          2 kB
          Thorsten Schöning

        Activity

          People

            pedrosans Pedro Santos
            tschoening Thorsten Schöning
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: