fireMatchNone causes IndexOutOfBoundsException

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

fireMatchNone causes IndexOutOfBoundsException

Magnus Larsson
fireMatchNone causes IndexOutOfBoundsException

Hi.
I'm quite inexperienced with GlazedLists (and certainly only an average Java coder) and I'm hoping someone could shed some light on a problem I'm having.

I just introduced a custom MatcherEditor in my application (thanks a lot for the latest screencast, it really made things a lot more clear than in the tutorial) and it works as expected when I use fireChanged and fireMatchAll to update the results. However, when I call fireMatchNone (called when the list selection is null) it results in an IndexOutOfBoundsException and I have no idea why.

The MatcherEditor is pretty much a copy of what was done in the screencast, except mine uses a ListSelectionListener.


Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
        at java.util.ArrayList.RangeCheck(ArrayList.java:547)
        at java.util.ArrayList.remove(ArrayList.java:390)
        at ca.odell.glazedlists.impl.gui.ThreadProxyEventList$UpdateRunner.listChanged(ThreadProxyEventList.java:153)
        at ca.odell.glazedlists.event.ListEventPublisher.fireEvent(ListEventPublisher.java:150)
        at ca.odell.glazedlists.event.ListEventAssembler.fireEvent(ListEventAssembler.java:272)
        at ca.odell.glazedlists.event.ListEventAssembler.commitEvent(ListEventAssembler.java:242)
        at ca.odell.glazedlists.impl.gui.ThreadProxyEventList$UpdateRunner.run(ThreadProxyEventList.java:137)
        at ca.odell.glazedlists.impl.swing.SwingThreadProxyEventList.schedule(SwingThreadProxyEventList.java:37)
        at ca.odell.glazedlists.impl.gui.ThreadProxyEventList.listChanged(ThreadProxyEventList.java:93)
        at ca.odell.glazedlists.event.ListEventPublisher.fireEvent(ListEventPublisher.java:150)
        at ca.odell.glazedlists.event.ListEventAssembler.fireEvent(ListEventAssembler.java:272)
        at ca.odell.glazedlists.event.ListEventAssembler.commitEvent(ListEventAssembler.java:242)
        at ca.odell.glazedlists.FilterList$PrivateMatcherEditorListener.matchNone(FilterList.java:273)
        at ca.odell.glazedlists.FilterList$PrivateMatcherEditorListener.changedMatcher(FilterList.java:246)
        at ca.odell.glazedlists.matchers.AbstractMatcherEditor.fireChangedMatcher(AbstractMatcherEditor.java:101)
        at ca.odell.glazedlists.matchers.AbstractMatcherEditor.fireMatchNone(AbstractMatcherEditor.java:91)
        at RPGen.VariantMatcherEditor.valueChanged(VariantMatcherEditor.java:28)
        at javax.swing.JList.fireSelectionValueChanged(JList.java:1317)
        at javax.swing.JList$ListSelectionHandler.valueChanged(JList.java:1331)
        at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:187)
        at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:167)
        at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:214)
        at javax.swing.DefaultListSelectionModel.changeSelection(DefaultListSelectionModel.java:408)
        at javax.swing.DefaultListSelectionModel.changeSelection(DefaultListSelectionModel.java:417)
        at javax.swing.DefaultListSelectionModel.removeSelectionIntervalImpl(DefaultListSelectionModel.java:510)
        at javax.swing.DefaultListSelectionModel.removeSelectionInterval(DefaultListSelectionModel.java:482)
        at javax.swing.JList.removeSelectionInterval(JList.java:1657)
        at javax.swing.plaf.basic.BasicListUI$Handler.adjustFocusAndSelection(BasicListUI.java:2296)
        at javax.swing.plaf.basic.BasicListUI$Handler.mousePressed(BasicListUI.java:2249)
        at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:222)
        at java.awt.Component.processMouseEvent(Component.java:5485)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3126)
        at java.awt.Component.processEvent(Component.java:5253)
        at java.awt.Container.processEvent(Container.java:1966)
        at java.awt.Component.dispatchEventImpl(Component.java:3955)
        at java.awt.Container.dispatchEventImpl(Container.java:2024)
        at java.awt.Component.dispatchEvent(Component.java:3803)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3889)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
        at java.awt.Container.dispatchEventImpl(Container.java:2010)
        at java.awt.Window.dispatchEventImpl(Window.java:1774)
        at java.awt.Component.dispatchEvent(Component.java:3803)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

Reply | Threaded
Open this post in threaded view
|

Re: fireMatchNone causes IndexOutOfBoundsException

James Lemieux
Magnus,

     Actually, you should have more confidence. Your code is fine! You have uncovered a tiny bug that was shipped in GlazedLists 0.9.7 and has since been fixed. We didn't expect anyone would find it so soon, as none of the Glazed Lists core calls fireMatchNone. Obviously we were wrong! I'm happy to hear you're writing custom matchers.

If you start using the lastest build from CVS (it's quite stable... no new dev work only tiny bug fixes) available here:

https://glazedlists.dev.java.net/files/documents/1073/18783/glazedlists.jar

then you can continue on your merry way.

Sorry for causing you some doubt.

Glaze On!

James

On 8/13/05, Magnus Larsson <[hidden email]> wrote:

Hi.
I'm quite inexperienced with GlazedLists (and certainly only an average Java coder) and I'm hoping someone could shed some light on a problem I'm having.

I just introduced a custom MatcherEditor in my application (thanks a lot for the latest screencast, it really made things a lot more clear than in the tutorial) and it works as expected when I use fireChanged and fireMatchAll to update the results. However, when I call fireMatchNone (called when the list selection is null) it results in an IndexOutOfBoundsException and I have no idea why.

The MatcherEditor is pretty much a copy of what was done in the screencast, except mine uses a ListSelectionListener.


Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
        at java.util.ArrayList.RangeCheck(ArrayList.java:547)
        at java.util.ArrayList.remove(ArrayList.java:390)
        at ca.odell.glazedlists.impl.gui.ThreadProxyEventList$UpdateRunner.listChanged(ThreadProxyEventList.java:153)
        at ca.odell.glazedlists.event.ListEventPublisher.fireEvent(ListEventPublisher.java:150)
        at ca.odell.glazedlists.event.ListEventAssembler.fireEvent(ListEventAssembler.java:272)
        at ca.odell.glazedlists.event.ListEventAssembler.commitEvent(ListEventAssembler.java:242)
        at ca.odell.glazedlists.impl.gui.ThreadProxyEventList$UpdateRunner.run(ThreadProxyEventList.java:137)
        at ca.odell.glazedlists.impl.swing.SwingThreadProxyEventList.schedule(SwingThreadProxyEventList.java:37)
        at ca.odell.glazedlists.impl.gui.ThreadProxyEventList.listChanged(ThreadProxyEventList.java:93)
        at ca.odell.glazedlists.event.ListEventPublisher.fireEvent(ListEventPublisher.java:150)
        at ca.odell.glazedlists.event.ListEventAssembler.fireEvent(ListEventAssembler.java:272)
        at ca.odell.glazedlists.event.ListEventAssembler.commitEvent(ListEventAssembler.java:242)
        at ca.odell.glazedlists.FilterList$PrivateMatcherEditorListener.matchNone(FilterList.java:273)
        at ca.odell.glazedlists.FilterList$PrivateMatcherEditorListener.changedMatcher(FilterList.java:246)
        at ca.odell.glazedlists.matchers.AbstractMatcherEditor.fireChangedMatcher(AbstractMatcherEditor.java:101)
        at ca.odell.glazedlists.matchers.AbstractMatcherEditor.fireMatchNone(AbstractMatcherEditor.java:91)
        at RPGen.VariantMatcherEditor.valueChanged(VariantMatcherEditor.java:28)
        at javax.swing.JList.fireSelectionValueChanged(JList.java:1317)
        at javax.swing.JList$ListSelectionHandler.valueChanged(JList.java:1331)
        at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:187)
        at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:167)
        at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:214)
        at javax.swing.DefaultListSelectionModel.changeSelection(DefaultListSelectionModel.java:408)
        at javax.swing.DefaultListSelectionModel.changeSelection(DefaultListSelectionModel.java:417)
        at javax.swing.DefaultListSelectionModel.removeSelectionIntervalImpl(DefaultListSelectionModel.java:510)
        at javax.swing.DefaultListSelectionModel.removeSelectionInterval(DefaultListSelectionModel.java:482)
        at javax.swing.JList.removeSelectionInterval(JList.java:1657)
        at javax.swing.plaf.basic.BasicListUI$Handler.adjustFocusAndSelection(BasicListUI.java:2296)
        at javax.swing.plaf.basic.BasicListUI$Handler.mousePressed(BasicListUI.java:2249)
        at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:222)
        at java.awt.Component.processMouseEvent(Component.java:5485)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3126)
        at java.awt.Component.processEvent(Component.java:5253)
        at java.awt.Container.processEvent(Container.java:1966)
        at java.awt.Component.dispatchEventImpl(Component.java:3955)
        at java.awt.Container.dispatchEventImpl(Container.java:2024)
        at java.awt.Component.dispatchEvent(Component.java:3803)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3889)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
        at java.awt.Container.dispatchEventImpl(Container.java:2010)
        at java.awt.Window.dispatchEventImpl(Window.java:1774)
        at java.awt.Component.dispatchEvent(Component.java:3803)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)