Exception

Hi, I get this exception. What am I doing wrong?
DF 1.1.1p6d

Exception in thread “AWT-EventQueue-0” java.lang.IndexOutOfBoundsException: Index: 4, Size: 4
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at bibliothek.gui.dock.themes.basic.action.buttons.ButtonPanel.getItemsOrdered(ButtonPanel.java:406)
at bibliothek.gui.dock.themes.basic.action.buttons.ButtonPanel.getPreferredSizes(ButtonPanel.java:452)
at bibliothek.gui.dock.station.stack.DockActionCombinedInfoComponent.getSizes(DockActionCombinedInfoComponent.java:169)
at bibliothek.gui.dock.station.stack.tab.MenuLineLayoutPane.listLayouts(MenuLineLayoutPane.java:225)
at bibliothek.gui.dock.station.stack.tab.MenuLineLayoutPane.getMinimumSize(MenuLineLayoutPane.java:124)
at bibliothek.gui.dock.station.stack.tab.MenuLineLayout.getMinimumSize(MenuLineLayout.java:77)
at bibliothek.gui.dock.station.stack.tab.AbstractTabPane.getMinimumSize(AbstractTabPane.java:141)
at bibliothek.gui.dock.station.stack.CombinedStackDockContentPane.getMinimumSize(CombinedStackDockContentPane.java:106)
at java.awt.GridLayout.minimumLayoutSize(GridLayout.java:373)
at java.awt.Container.minimumSize(Container.java:1651)
at java.awt.Container.getMinimumSize(Container.java:1636)
at javax.swing.JComponent.getMinimumSize(JComponent.java:1716)
at bibliothek.gui.dock.station.split.Leaf.getMinimumSize(Leaf.java:89)
at bibliothek.gui.dock.station.split.Root.getMinimumSize(Root.java:168)
at bibliothek.gui.dock.SplitDockStation.getMinimumSize(SplitDockStation.java:495)
at java.awt.GridLayout.minimumLayoutSize(GridLayout.java:373)
at java.awt.Container.minimumSize(Container.java:1651)
at java.awt.Container.getMinimumSize(Container.java:1636)
at javax.swing.JComponent.getMinimumSize(JComponent.java:1716)
at bibliothek.gui.dock.station.split.Leaf.getMinimumSize(Leaf.java:89)
at bibliothek.gui.dock.station.split.Node.getMinimumSize(Node.java:262)
at bibliothek.gui.dock.station.split.DefaultSplitLayoutManager.validateDivider(DefaultSplitLayoutManager.java:286)
at bibliothek.gui.dock.facile.station.split.DelegatingSplitLayoutManager.validateDivider(DelegatingSplitLayoutManager.java:76)
at bibliothek.gui.dock.SplitDockStation$Access.validateDivider(SplitDockStation.java:2967)
at bibliothek.gui.dock.station.split.Node.updateBounds(Node.java:361)
at bibliothek.gui.dock.station.split.Root.updateBounds(Root.java:317)
at bibliothek.gui.dock.station.split.DefaultSplitLayoutManager.updateBounds(DefaultSplitLayoutManager.java:369)
at bibliothek.gui.dock.facile.station.split.DelegatingSplitLayoutManager.updateBounds(DelegatingSplitLayoutManager.java:72)
at bibliothek.gui.dock.facile.station.split.LockedResizeLayoutManager.updateBounds(LockedResizeLayoutManager.java:107)
at bibliothek.gui.dock.SplitDockStation.updateBounds(SplitDockStation.java:2627)
at bibliothek.gui.dock.SplitDockStation$Content.doLayout(SplitDockStation.java:2660)
at java.awt.Container.validateTree(Container.java:1507)
at java.awt.Container.validateTree(Container.java:1513)
at java.awt.Container.validateTree(Container.java:1513)
at java.awt.Container.validateTree(Container.java:1513)
at java.awt.Container.validateTree(Container.java:1513)
at java.awt.Container.validateTree(Container.java:1513)
at java.awt.Container.validateTree(Container.java:1513)
at java.awt.Container.validate(Container.java:1480)
at javax.swing.RepaintManager.validateInvalidComponents(RepaintManager.java:669)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:124)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:642)
at java.awt.EventQueue.access$000(EventQueue.java:85)
at java.awt.EventQueue$1.run(EventQueue.java:603)
at java.awt.EventQueue$1.run(EventQueue.java:601)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:612)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

Does not look as if you are doing something wrong. Does it happen all the times? You have any code that produces this exception? I’ll try to reproduce the bug in the evening.

The only explanation I have is a multi threading issue. Are you setting some properties from a thread that is not the EDT after the windows/frames were made visible?

Because if you look at the code where the exception happens, it’s rather easy to show that the exception can only happen if the size of the list of action changes while the “getItemsOrdered” method runs. This can only happen if another thread accesses the list.


	private ActionItem[] getItemsOrdered(){
		DockAction[] actions = new DockAction[ this.actions.size() ];  // actions.length == this.actions.size()
		for( int i = 0; i < actions.length; i++ ){
			actions** = this.actions.get( i ).action;
		}
		actionOrder.getValue().order( actions );
		
		int index = 0;
		int next = 0;
		int length = actions.length;  // length = this.actions.length
		ActionItem[] result = new ActionItem[ length ];
		boolean[] used = new boolean[ length ];
		
		loop:for( DockAction action : actions ){
			for( int i = next; i < length; i++ ){
				if( !used[ i ]){

				// this is where the exception happens. 
				// i < length, hence i < actions.length, hence i < this.actions.size()

					ActionItem item = this.actions.get( i ); 

Thank You for answer.
It’s my fault :wink: