Uploaded image for project: 'Commons Collections'
  1. Commons Collections
  2. COLLECTIONS-447

TreeListIterator can return incorrect results after remove() is called

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: Nightly Builds
    • Fix Version/s: 3.2.2, 4.0-alpha1, 4.0
    • Component/s: Collection
    • Labels:
    • Environment:

      Windows 7, jdk1.5.0_22

      Description

      TreeList.TreeListIterator can get in a bad state when remove() is called, causing it to subsequently return incorrect results. This is because TreeListIterator caches an AVLNode reference in its field next, and this node reference may become stale when remove() is called (it may contain a reference to a node that no longer exists in the tree).

      I will attach two patches: testcase.patch will contain a test case illustrating the bug, and fix.patch will contain a fix. (To fix the bug, I simply clear the cached next value in TreeListIterator.remove.)

      This was originally reported in a comment to COLLECTIONS-433; I am creating a separate issue for this at Thomas Neidhart's suggestion.

        Attachments

        1. testcase.patch
          1 kB
          Jeffrey Barnes
        2. fix.patch
          1 kB
          Jeffrey Barnes

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                jbarnes Jeffrey Barnes
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: