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

Encountered an IllegalStateException while traversing with Flat3Map.entrySet()

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.0
    • 4.5.0-M1
    • Map
    • None

    Description

      Encountered an IllegalStateException while traversing with Flat3Map.entrySet()

      //代码示例
          public void testEntrySet() {
              final Flat3Map<Integer, String> map = new Flat3Map<>();
              map.put(1, "A");
              map.put(2, "B");
              map.put(3, "C");
              Iterator<Map.Entry<Integer, String>> it = map.entrySet().iterator();        Map.Entry<Integer, String> mapEntry1 = it.next();
              Map.Entry<Integer, String> mapEntry2 = it.next();
              Map.Entry<Integer, String> mapEntry3 = it.next();
              it.remove();        assertEquals(2, map.size());
          }
      

      Using the above code will generate an IllegalStateException.
      The reason for this problem is that there is a problem with the EntryIterator.remove() method in the Flat3Map java class.

      I submitted a PR(https://github.com/apache/commons-collections/pull/115) to fix this bug.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              Guoping1 Chen
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m