[JIRA] (GLAZEDLISTS-458) AutoCompleteSupport causes IndexOutOfBoundsException

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[JIRA] (GLAZEDLISTS-458) AutoCompleteSupport causes IndexOutOfBoundsException

JIRA jira-no-reply@java.net

    [ https://java.net/jira/browse/GLAZEDLISTS-458?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=394552#comment-394552 ]

jhuxhorn commented on GLAZEDLISTS-458:
--------------------------------------

Works for me on macOS Sierra 10.12.3 with {{net.java.dev.glazedlists:glazedlists_java15:1.9.1}}

java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)

java version "9-ea"
Java(TM) SE Runtime Environment (build 9-ea+158)

> AutoCompleteSupport causes IndexOutOfBoundsException
> ----------------------------------------------------
>
>                 Key: GLAZEDLISTS-458
>                 URL: https://java.net/jira/browse/GLAZEDLISTS-458
>             Project: glazedlists
>          Issue Type: Bug
>          Components: swing
>    Affects Versions: 1.7.0
>         Environment: Operating System: Mac OS X
> Platform: Macintosh
>            Reporter: niklass
>            Assignee: jessewilson
>             Fix For: milestone 1
>
>
> I get the Exception when i erase with backspace after adding text that doesn't match any of the available options.
> Here is my simple test class that i used to reproduce the bug:
> import ca.odell.glazedlists.EventList;
> import ca.odell.glazedlists.GlazedLists;
> import ca.odell.glazedlists.swing.AutoCompleteSupport;
> import java.util.ArrayList;
> import java.util.List;
> import javax.swing.JComboBox;
> public class AutoCompleteBug extends javax.swing.JDialog {
>     public AutoCompleteBug(java.awt.Frame parent, boolean modal) {
>         super(parent, modal);
>        
>         JComboBox jComboBox1 = new JComboBox();
>         add(jComboBox1);
>         jComboBox1.setVisible(true);
>         pack();
>         AutoCompleteSupport<String> support;
>         List<String> list = new ArrayList();
>         list.add("abc");
>         list.add("bcd");
>         list.add("cde");
>         EventList<String> eventList = GlazedLists.eventList(list);
>         support = AutoCompleteSupport.install(jComboBox1, eventList);
>         support.setStrict(false);
>     }
>     public static void main(String args[]) {
>         java.awt.EventQueue.invokeLater(new Runnable() {
>             public void run() {
>                 AutoCompleteBug dialog = new AutoCompleteBug(new javax.swing.JFrame(), true);
>                 dialog.addWindowListener(new java.awt.event.WindowAdapter() {
>                     @Override
>                     public void windowClosing(java.awt.event.WindowEvent e) {
>                         System.exit(0);
>                     }
>                 });
>                 dialog.setVisible(true);
>             }
>         });
>     }
> }
> Here are my steps to reproduce the bug:
> 1. Compile the class and then run it.
> 2. Type "as" into the textfield
> 3. Erase the "s" by pressing backspace key.
> 4. In standard out i get:  
> 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.get(ArrayList.java:322)
>         at ca.odell.glazedlists.impl.gui.ThreadProxyEventList.applyChangeToCache(ThreadProxyEventList.java:146)
>         at ca.odell.glazedlists.impl.gui.ThreadProxyEventList$UpdateRunner.listChanged(ThreadProxyEventList.java:196)
>         at ca.odell.glazedlists.event.ListEventAssembler$ListSequencePublisherAdapter$ListEventFormat.fire(ListEventAssembler.java:869)
>         at ca.odell.glazedlists.event.ListEventAssembler$ListSequencePublisherAdapter$ListEventFormat.fire(ListEventAssembler.java:861)
>         at ca.odell.glazedlists.event.SequenceDependenciesEventPublisher$SubjectAndListener.firePendingEvent(SequenceDependenciesEventPublisher.java:435)
>         at ca.odell.glazedlists.event.SequenceDependenciesEventPublisher.fireEvent(SequenceDependenciesEventPublisher.java:334)
>         at ca.odell.glazedlists.event.ListEventAssembler$ListSequencePublisherAdapter.fireEvent(ListEventAssembler.java:855)
>         at ca.odell.glazedlists.event.ListEventAssembler$AssemblerHelper.commitEvent(ListEventAssembler.java:389)
>         at ca.odell.glazedlists.event.ListEventAssembler.commitEvent(ListEventAssembler.java:226)
>         at ca.odell.glazedlists.FilterList.constrained(FilterList.java:375)
>         at ca.odell.glazedlists.FilterList.changeMatcher(FilterList.java:277)
>         at ca.odell.glazedlists.FilterList.changeMatcherWithLocks(FilterList.java:260)
>         at ca.odell.glazedlists.FilterList.access$100(FilterList.java:45)
>         at ca.odell.glazedlists.FilterList$PrivateMatcherEditorListener.changedMatcher(FilterList.java:428)
>         at ca.odell.glazedlists.matchers.AbstractMatcherEditor.fireChangedMatcher(AbstractMatcherEditor.java:101)
>         at ca.odell.glazedlists.matchers.AbstractMatcherEditor.fireConstrained(AbstractMatcherEditor.java:73)
>         at ca.odell.glazedlists.matchers.TextMatcherEditor.setFilterText(TextMatcherEditor.java:163)
>         at ca.odell.glazedlists.swing.AutoCompleteSupport.applyFilter(AutoCompleteSupport.java:984)
>         at ca.odell.glazedlists.swing.AutoCompleteSupport.access$2200(AutoCompleteSupport.java:154)
>         at ca.odell.glazedlists.swing.AutoCompleteSupport$AutoCompleteFilter.postProcessDocumentChange(AutoCompleteSupport.java:1169)
>         at ca.odell.glazedlists.swing.AutoCompleteSupport$AutoCompleteFilter.remove(AutoCompleteSupport.java:1120)
>         at javax.swing.text.AbstractDocument.remove(AbstractDocument.java:573)
>         at javax.swing.text.DefaultEditorKit$DeletePrevCharAction.actionPerformed(DefaultEditorKit.java:1050)
>         at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1641)
>         at javax.swing.JComponent.processKeyBinding(JComponent.java:2849)
>         at javax.swing.JComponent.processKeyBindings(JComponent.java:2884)
>         at javax.swing.JComponent.processKeyEvent(JComponent.java:2812)
>         at java.awt.Component.processEvent(Component.java:5903)
>         at java.awt.Container.processEvent(Container.java:2102)
>         at java.awt.Component.dispatchEventImpl(Component.java:4497)
>         at java.awt.Container.dispatchEventImpl(Container.java:2160)
>         at java.awt.Component.dispatchEvent(Component.java:4327)
>         at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1848)
>         at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:697)
>         at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:962)
>         at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:834)
>         at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:661)
>         at java.awt.Component.dispatchEventImpl(Component.java:4369)
>         at java.awt.Container.dispatchEventImpl(Container.java:2160)
>         at java.awt.Window.dispatchEventImpl(Window.java:2440)
>         at java.awt.Component.dispatchEvent(Component.java:4327)
>         at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
>         at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:300)
>         at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:210)
>         at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:204)
>         at java.awt.Dialog$1.run(Dialog.java:1045)
>         at java.awt.Dialog$3.run(Dialog.java:1097)
>         at java.security.AccessController.doPrivileged(Native Method)
>         at java.awt.Dialog.show(Dialog.java:1095)
>         at java.awt.Component.show(Component.java:1422)
>         at java.awt.Component.setVisible(Component.java:1375)
>         at java.awt.Window.setVisible(Window.java:806)
>         at java.awt.Dialog.setVisible(Dialog.java:985)
>         at AutoCompleteBug$1.run(AutoCompleteBug.java:40)
>         at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
>         at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
>         at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:300)
>         at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:210)
>         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:200)
>         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:195)
>         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:187)
>         at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)



--
This message was sent by Atlassian JIRA
(v6.2.3#6260)