Pivot
  1. Pivot
  2. PIVOT-278

ArrayList.update(): illegal item modification check is too strict

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.3
    • Fix Version/s: 1.3
    • Component/s: wtk
    • Labels:
      None

      Description

      The editor is behaving incorrectly in many ways. Investigation is needed.

        Activity

        Hide
        Todd Volkert added a comment -

        Reproducible use case:

        1) Expand "Location"->"South America" in the editable trees section of the kitchen sink demo
        2) Click to edit "Africa"
        3) Enter something that will get sorted after "South America", like "Zafrica"

        Result:

        java.lang.IllegalArgumentException: Illegal item modification.
        at org.apache.pivot.collections.ArrayList.update(ArrayList.java:264)
        at org.apache.pivot.wtk.TreeView$BranchHandler.clearAndDecrementPaths(TreeView.java:649)
        at org.apache.pivot.wtk.TreeView$BranchHandler.itemsRemoved(TreeView.java:467)
        at org.apache.pivot.collections.List$ListListenerList.itemsRemoved(List.java:53)
        at org.apache.pivot.wtk.content.TreeBranch.remove(TreeBranch.java:105)
        at org.apache.pivot.wtk.content.TreeViewNodeEditor.save(TreeViewNodeEditor.java:289)
        at org.apache.pivot.wtk.content.TreeViewNodeEditor$2.keyPressed(TreeViewNodeEditor.java:88)
        at org.apache.pivot.wtk.Component$ComponentKeyListenerList.keyPressed(Component.java:555)
        at org.apache.pivot.wtk.Component.keyPressed(Component.java:2616)
        at org.apache.pivot.wtk.ApplicationContext$DisplayHost.processKeyEvent(ApplicationContext.java:1207)
        at java.awt.Component.processEvent(Component.java:6125)
        at java.awt.Component.dispatchEventImpl(Component.java:4714)
        at java.awt.Component.dispatchEvent(Component.java:4544)
        at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1848)
        at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:704)
        at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:969)
        at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:841)
        at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:668)
        at java.awt.Component.dispatchEventImpl(Component.java:4586)
        at java.awt.Component.dispatchEvent(Component.java:4544)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:635)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

        After this exception, all hell breaks loose

        Show
        Todd Volkert added a comment - Reproducible use case: 1) Expand "Location"->"South America" in the editable trees section of the kitchen sink demo 2) Click to edit "Africa" 3) Enter something that will get sorted after "South America", like "Zafrica" Result: java.lang.IllegalArgumentException: Illegal item modification. at org.apache.pivot.collections.ArrayList.update(ArrayList.java:264) at org.apache.pivot.wtk.TreeView$BranchHandler.clearAndDecrementPaths(TreeView.java:649) at org.apache.pivot.wtk.TreeView$BranchHandler.itemsRemoved(TreeView.java:467) at org.apache.pivot.collections.List$ListListenerList.itemsRemoved(List.java:53) at org.apache.pivot.wtk.content.TreeBranch.remove(TreeBranch.java:105) at org.apache.pivot.wtk.content.TreeViewNodeEditor.save(TreeViewNodeEditor.java:289) at org.apache.pivot.wtk.content.TreeViewNodeEditor$2.keyPressed(TreeViewNodeEditor.java:88) at org.apache.pivot.wtk.Component$ComponentKeyListenerList.keyPressed(Component.java:555) at org.apache.pivot.wtk.Component.keyPressed(Component.java:2616) at org.apache.pivot.wtk.ApplicationContext$DisplayHost.processKeyEvent(ApplicationContext.java:1207) at java.awt.Component.processEvent(Component.java:6125) at java.awt.Component.dispatchEventImpl(Component.java:4714) at java.awt.Component.dispatchEvent(Component.java:4544) at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1848) at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:704) at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:969) at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:841) at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:668) at java.awt.Component.dispatchEventImpl(Component.java:4586) at java.awt.Component.dispatchEvent(Component.java:4544) at java.awt.EventQueue.dispatchEvent(EventQueue.java:635) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188) at java.awt.EventDispatchThread.run(EventDispatchThread.java:122) After this exception, all hell breaks loose
        Hide
        Todd Volkert added a comment -

        This bug is actually in the following code in ArrayList.update():

        if (comparator != null
        && binarySearch(this, item, comparator) != index)

        { throw new IllegalArgumentException("Illegal item modification."); }

        The issue is that we are updating the existing item with one that will end up in the same place (given the comparator), but since the updated item is not yet in the list, the check above throws the exception.

        Example:

        List: [[1], [1, 6]]
        index: 1
        newItem: [1, 5]

        Show
        Todd Volkert added a comment - This bug is actually in the following code in ArrayList.update(): if (comparator != null && binarySearch(this, item, comparator) != index) { throw new IllegalArgumentException("Illegal item modification."); } The issue is that we are updating the existing item with one that will end up in the same place (given the comparator), but since the updated item is not yet in the list, the check above throws the exception. Example: List: [ [1] , [1, 6] ] index: 1 newItem: [1, 5]
        Hide
        Todd Volkert added a comment -

        Note that this same issue exists in ListAdapter

        Show
        Todd Volkert added a comment - Note that this same issue exists in ListAdapter

          People

          • Assignee:
            Unassigned
            Reporter:
            Todd Volkert
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development