Contacts did not show correctly

I use spark 2.5.8, and use smack test case to login 80 users. But sometimes, some contacts still show online, when all the test users logged out. And it has following errors:

Exception in thread “AWT-EventQueue-0” java.lang.ArrayIndexOutOfBoundsException: 994 >= 994

at java.util.Vector.elementAt(Vector.java:427)

at javax.swing.DefaultListModel.getElementAt(DefaultListModel.java:70)

at javax.swing.plaf.basic.BasicListUI.updateLayoutState(BasicListUI.java:1343)

at javax.swing.plaf.basic.BasicListUI.maybeUpdateLayoutState(BasicListUI.java:1294 )

at javax.swing.plaf.basic.BasicListUI.paintImpl(BasicListUI.java:246)

at javax.swing.plaf.basic.BasicListUI.paint(BasicListUI.java:222)

at javax.swing.plaf.synth.SynthListUI.update(SynthListUI.java:52)

at javax.swing.JComponent.paintComponent(JComponent.java:752)

at javax.swing.JComponent.paint(JComponent.java:1029)

at javax.swing.JComponent.paintChildren(JComponent.java:862)

at javax.swing.JComponent.paint(JComponent.java:1038)

at javax.swing.JComponent.paintChildren(JComponent.java:862)

at javax.swing.JComponent.paint(JComponent.java:1038)

at javax.swing.JComponent.paintChildren(JComponent.java:862)

at javax.swing.JComponent.paint(JComponent.java:1038)

at javax.swing.JComponent.paintChildren(JComponent.java:862)

at javax.swing.JComponent.paint(JComponent.java:1038)

at javax.swing.JComponent.paintChildren(JComponent.java:862)

at javax.swing.JComponent.paint(JComponent.java:1038)

at javax.swing.JViewport.paint(JViewport.java:747)

at javax.swing.JComponent.paintChildren(JComponent.java:862)

at javax.swing.JComponent.paint(JComponent.java:1038)

at javax.swing.JComponent.paintChildren(JComponent.java:862)

at javax.swing.JComponent.paint(JComponent.java:1038)

at javax.swing.JComponent.paintToOffscreen(JComponent.java:5124)

at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:27 8)

at javax.swing.RepaintManager.paint(RepaintManager.java:1224)

at javax.swing.JComponent._paintImmediately(JComponent.java:5072)

at javax.swing.JComponent.paintImmediately(JComponent.java:4882)

at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:785)

at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:713)

at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:693)

at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueue Utilities.java:125)

at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)

at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:641)

at java.awt.EventQueue.access$000(EventQueue.java:84)

at java.awt.EventQueue$1.run(EventQueue.java:602)

at java.awt.EventQueue$1.run(EventQueue.java:600)

at java.security.AccessController.doPrivileged(Native Method)

at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlConte xt.java:87)

at java.awt.EventQueue.dispatchEvent(EventQueue.java:611)

at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:26 9)

at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:17 4)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

Exception in thread “AWT-EventQueue-0” java.lang.ArrayIndexOutOfBoundsException: 994 >= 994

at java.util.Vector.elementAt(Vector.java:427)

at javax.swing.DefaultListModel.getElementAt(DefaultListModel.java:70)

at javax.swing.plaf.basic.BasicListUI.updateLayoutState(BasicListUI.java:1343)

at javax.swing.plaf.basic.BasicListUI.maybeUpdateLayoutState(BasicListUI.java:1294 )

at javax.swing.plaf.basic.BasicListUI.getPreferredSize(BasicListUI.java:561)

at javax.swing.JComponent.getPreferredSize(JComponent.java:1634)

at org.jivesoftware.spark.component.VerticalFlowLayout.preferredLayoutSize(Vertica lFlowLayout.java:121)

at java.awt.Container.preferredSize(Container.java:1599)

at java.awt.Container.getPreferredSize(Container.java:1584)

at javax.swing.JComponent.getPreferredSize(JComponent.java:1636)

at java.awt.BorderLayout.preferredLayoutSize(BorderLayout.java:702)

at java.awt.Container.preferredSize(Container.java:1599)

at java.awt.Container.getPreferredSize(Container.java:1584)

at javax.swing.JComponent.getPreferredSize(JComponent.java:1636)

at java.awt.BorderLayout.preferredLayoutSize(BorderLayout.java:702)

at java.awt.Container.preferredSize(Container.java:1599)

at java.awt.Container.getPreferredSize(Container.java:1584)

at javax.swing.JComponent.getPreferredSize(JComponent.java:1636)

at org.jivesoftware.spark.ui.ContactGroup.getPreferredSize(ContactGroup.java:821)

at org.jivesoftware.spark.component.VerticalFlowLayout.preferredLayoutSize(Vertica lFlowLayout.java:121)

at java.awt.Container.preferredSize(Container.java:1599)

at java.awt.Container.getPreferredSize(Container.java:1584)

at javax.swing.JComponent.getPreferredSize(JComponent.java:1636)

at javax.swing.ScrollPaneLayout.layoutContainer(ScrollPaneLayout.java:769)

at java.awt.Container.layout(Container.java:1421)

at java.awt.Container.doLayout(Container.java:1410)

at java.awt.Container.validateTree(Container.java:1507)

at java.awt.Container.validate(Container.java:1480)

at javax.swing.RepaintManager.validateInvalidComponents(RepaintManager.java:669)

at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueue Utilities.java:124)

at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)

at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:641)

at java.awt.EventQueue.access$000(EventQueue.java:84)

at java.awt.EventQueue$1.run(EventQueue.java:602)

at java.awt.EventQueue$1.run(EventQueue.java:600)

at java.security.AccessController.doPrivileged(Native Method)

at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlConte xt.java:87)

at java.awt.EventQueue.dispatchEvent(EventQueue.java:611)

at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:26 9)

at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:17 4)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

Exception in thread “AWT-EventQueue-0” java.lang.ArrayIndexOutOfBoundsException: 992 >= 992

at java.util.Vector.elementAt(Vector.java:427)

at javax.swing.DefaultListModel.getElementAt(DefaultListModel.java:70)

at javax.swing.plaf.basic.BasicListUI.updateLayoutState(BasicListUI.java:1343)

at javax.swing.plaf.basic.BasicListUI.maybeUpdateLayoutState(BasicListUI.java:1294 )

at javax.swing.plaf.basic.BasicListUI.paintImpl(BasicListUI.java:246)

at javax.swing.plaf.basic.BasicListUI.paint(BasicListUI.java:222)

at javax.swing.plaf.synth.SynthListUI.update(SynthListUI.java:52)

at javax.swing.JComponent.paintComponent(JComponent.java:752)

at javax.swing.JComponent.paint(JComponent.java:1029)

at javax.swing.JComponent.paintToOffscreen(JComponent.java:5124)

at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:27 8)

at javax.swing.RepaintManager.paint(RepaintManager.java:1224)

at javax.swing.JComponent._paintImmediately(JComponent.java:5072)

at javax.swing.JComponent.paintImmediately(JComponent.java:4882)

at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:785)

at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:713)

at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:693)

at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueue Utilities.java:125)

at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)

at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:641)

at java.awt.EventQueue.access$000(EventQueue.java:84)

at java.awt.EventQueue$1.run(EventQueue.java:602)

at java.awt.EventQueue$1.run(EventQueue.java:600)

at java.security.AccessController.doPrivileged(Native Method)

at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlConte xt.java:87)

at java.awt.EventQueue.dispatchEvent(EventQueue.java:611)

at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:26 9)

at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:17 4)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

Exception in thread “AWT-EventQueue-0” java.lang.ArrayIndexOutOfBoundsException: 996 >= 996

at java.util.Vector.elementAt(Vector.java:427)

at javax.swing.DefaultListModel.getElementAt(DefaultListModel.java:70)

at javax.swing.plaf.basic.BasicListUI.updateLayoutState(BasicListUI.java:1343)

at javax.swing.plaf.basic.BasicListUI.maybeUpdateLayoutState(BasicListUI.java:1294 )

at javax.swing.plaf.basic.BasicListUI.getPreferredSize(BasicListUI.java:561)

at javax.swing.JComponent.getPreferredSize(JComponent.java:1634)

at org.jivesoftware.spark.component.VerticalFlowLayout.preferredLayoutSize(Vertica lFlowLayout.java:121)

at java.awt.Container.preferredSize(Container.java:1599)

at java.awt.Container.getPreferredSize(Container.java:1584)

at javax.swing.JComponent.getPreferredSize(JComponent.java:1636)

at java.awt.BorderLayout.preferredLayoutSize(BorderLayout.java:702)

at java.awt.Container.preferredSize(Container.java:1599)

at java.awt.Container.getPreferredSize(Container.java:1584)

at javax.swing.JComponent.getPreferredSize(JComponent.java:1636)

at java.awt.BorderLayout.preferredLayoutSize(BorderLayout.java:702)

at java.awt.Container.preferredSize(Container.java:1599)

at java.awt.Container.getPreferredSize(Container.java:1584)

at javax.swing.JComponent.getPreferredSize(JComponent.java:1636)

at org.jivesoftware.spark.ui.ContactGroup.getPreferredSize(ContactGroup.java:821)

at org.jivesoftware.spark.component.VerticalFlowLayout.preferredLayoutSize(Vertica lFlowLayout.java:121)

at java.awt.Container.preferredSize(Container.java:1599)

at java.awt.Container.getPreferredSize(Container.java:1584)

at javax.swing.JComponent.getPreferredSize(JComponent.java:1636)

at javax.swing.ScrollPaneLayout.layoutContainer(ScrollPaneLayout.java:769)

at java.awt.Container.layout(Container.java:1421)

at java.awt.Container.doLayout(Container.java:1410)

at java.awt.Container.validateTree(Container.java:1507)

at java.awt.Container.validate(Container.java:1480)

at javax.swing.RepaintManager.validateInvalidComponents(RepaintManager.java:669)

at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueue Utilities.java:124)

at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)

at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:641)

at java.awt.EventQueue.access$000(EventQueue.java:84)

at java.awt.EventQueue$1.run(EventQueue.java:602)

at java.awt.EventQueue$1.run(EventQueue.java:600)

at java.security.AccessController.doPrivileged(Native Method)

at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlConte xt.java:87)

at java.awt.EventQueue.dispatchEvent(EventQueue.java:611)

at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:26 9)

at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:17 4)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

Exception in thread “AWT-EventQueue-0” java.lang.ArrayIndexOutOfBoundsException: 993 >= 993

at java.util.Vector.elementAt(Vector.java:427)

at javax.swing.DefaultListModel.getElementAt(DefaultListModel.java:70)

at javax.swing.plaf.basic.BasicListUI.updateLayoutState(BasicListUI.java:1343)

at javax.swing.plaf.basic.BasicListUI.maybeUpdateLayoutState(BasicListUI.java:1294 )

at javax.swing.plaf.basic.BasicListUI.paintImpl(BasicListUI.java:246)

at javax.swing.plaf.basic.BasicListUI.paint(BasicListUI.java:222)

at javax.swing.plaf.synth.SynthListUI.update(SynthListUI.java:52)

at javax.swing.JComponent.paintComponent(JComponent.java:752)

at javax.swing.JComponent.paint(JComponent.java:1029)

at javax.swing.JComponent.paintChildren(JComponent.java:862)

at javax.swing.JComponent.paint(JComponent.java:1038)

at javax.swing.JComponent.paintChildren(JComponent.java:862)

at javax.swing.JComponent.paint(JComponent.java:1038)

at javax.swing.JComponent.paintChildren(JComponent.java:862)

at javax.swing.JComponent.paint(JComponent.java:1038)

at javax.swing.JComponent.paintChildren(JComponent.java:862)

at javax.swing.JComponent.paint(JComponent.java:1038)

at javax.swing.JComponent.paintChildren(JComponent.java:862)

at javax.swing.JComponent.paint(JComponent.java:1038)

at javax.swing.JViewport.paint(JViewport.java:747)

at javax.swing.JComponent.paintChildren(JComponent.java:862)

at javax.swing.JComponent.paint(JComponent.java:1038)

at javax.swing.JComponent.paintChildren(JComponent.java:862)

at javax.swing.JComponent.paint(JComponent.java:1038)

at javax.swing.JComponent.paintToOffscreen(JComponent.java:5124)

at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:27 8)

at javax.swing.RepaintManager.paint(RepaintManager.java:1224)

at javax.swing.JComponent._paintImmediately(JComponent.java:5072)

at javax.swing.JComponent.paintImmediately(JComponent.java:4882)

at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:785)

at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:713)

at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:693)

at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueue Utilities.java:125)

at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)

at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:641)

at java.awt.EventQueue.access$000(EventQueue.java:84)

at java.awt.EventQueue$1.run(EventQueue.java:602)

at java.awt.EventQueue$1.run(EventQueue.java:600)

at java.security.AccessController.doPrivileged(Native Method)

at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlConte xt.java:87)

at java.awt.EventQueue.dispatchEvent(EventQueue.java:611)

at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:26 9)

at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:17 4)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

It also has another problem that some contacts show offline when the test users logged in. It is caused by multithreading problem. When class ContactGroup sorts the contacts, another contact is added, so the sort method throws a ArrayIndexOutOfBoundsException. I have fixed the problem by set all method which related contactItems to synchronized method.

I don’t know spark 2.6.3 whether has this problem.

Can anybody help me?

I have do many changes in the 2.5.8’ s source code, so it best not to change to 2.6.3. And I test with 2.6.3, it also have this problem.

I think it’s the problem that some thread changed the contact list when swing repaint the UI.