This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 395839 - AbstractEList$BasicIndexOutOfBoundsException when opening a context menu
Summary: AbstractEList$BasicIndexOutOfBoundsException when opening a context menu
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.3   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 4.3.1   Edit
Assignee: Daniel Rolka CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 383734 (view as bug list)
Depends on:
Blocks: 407084
  Show dependency tree
 
Reported: 2012-12-05 12:00 EST by Remy Suen CLA
Modified: 2013-08-29 04:31 EDT (History)
10 users (show)

See Also:


Attachments
MenuManagerRenderer patch v1 (1.76 KB, patch)
2012-12-05 12:00 EST, Remy Suen CLA
no flags Details | Diff
Test project that reproduces the problem. (7.05 KB, application/octet-stream)
2012-12-05 14:35 EST, Remy Suen CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Remy Suen CLA 2012-12-05 12:00:21 EST
Created attachment 224320 [details]
MenuManagerRenderer patch v1

We have a view with two context menu registrations with the same tree viewer but different selection providers (don't ask me why). On the second notification to the MenuManager's listeners (it has 2, both from PopupMenuExtender), the exception below gets thrown.

I have attached a patch that fixes the problem though it's not clear to me if this is the right fix. I did not alter the code that affects menu manager because that doesn't cause problems on our end. If this is the right fix, perhaps the same fix should be applied for the code that affects menu managers?

org.eclipse.emf.common.util.AbstractEList$BasicIndexOutOfBoundsException: index=26, size=22
	at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:332)
	at org.eclipse.e4.ui.workbench.renderers.swt.MenuManagerRenderer.reconcileManagerToModel(MenuManagerRenderer.java:894)
	at org.eclipse.ui.internal.PopupMenuExtender.addMenuContributions(PopupMenuExtender.java:405)
	at org.eclipse.ui.internal.PopupMenuExtender.menuAboutToShow(PopupMenuExtender.java:379)
	at org.eclipse.jface.action.MenuManager.fireAboutToShow(MenuManager.java:343)
	at org.eclipse.jface.action.MenuManager.handleAboutToShow(MenuManager.java:475)
	at org.eclipse.jface.action.MenuManager.access$1(MenuManager.java:470)
	at org.eclipse.jface.action.MenuManager$2.menuShown(MenuManager.java:500)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:255)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1058)
	at org.eclipse.swt.widgets.Control.WM_INITMENUPOPUP(Control.java:4881)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4557)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:340)
	at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1627)
	at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:2069)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4976)
	at org.eclipse.swt.internal.win32.OS.TrackPopupMenu(Native Method)
	at org.eclipse.swt.widgets.Menu._setVisible(Menu.java:257)
	at org.eclipse.swt.widgets.Display.runPopups(Display.java:4210)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3752)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1021)
Comment 1 Remy Suen CLA 2012-12-05 14:35:14 EST
Created attachment 224330 [details]
Test project that reproduces the problem.

The attached project will reproduce the problem. However, it may be contrived in the sense that we're adding two contribution items to the menu manager where equals(Object) returns true. Changing the maps in MenuManagerRenderer to be implementations of IdentityHashMap appears to be an alternate fix to the problem (besides what's been suggested in attachment 224320 [details]).
Comment 2 Heiko Böttger CLA 2013-01-16 02:32:03 EST
This looks like the same as https://bugs.eclipse.org/bugs/show_bug.cgi?id=383734.
Comment 3 Paul Webster CLA 2013-01-16 07:02:00 EST
*** Bug 383734 has been marked as a duplicate of this bug. ***
Comment 4 Paul Webster CLA 2013-02-11 13:35:54 EST
(In reply to comment #1)
> The attached project will reproduce the problem. However, it may be
> contrived in the sense that we're adding two contribution items to the menu
> manager where equals(Object) returns true. Changing the maps in
> MenuManagerRenderer to be implementations of IdentityHashMap appears to be
> an alternate fix to the problem (besides what's been suggested in attachment
> 224320 [details]).

Is it the maps with MenuManager and and IContributionItem as keys that need to be IdentityHashMaps?

PW
Comment 5 Remy Suen CLA 2013-02-20 16:56:39 EST
(In reply to comment #4)
> (In reply to comment #1)
> > Changing the maps in
> > MenuManagerRenderer to be implementations of IdentityHashMap appears to be
> > an alternate fix to the problem (besides what's been suggested in attachment
> > 224320 [details]).
> 
> Is it the maps with MenuManager and and IContributionItem as keys that need
> to be IdentityHashMaps?

Don't quite remember the details I'm afraid.
Comment 6 Daniel Rolka CLA 2013-04-15 04:40:11 EDT
Patch with change: https://git.eclipse.org/r/#/c/11812/
Comment 8 Praveen Bahl CLA 2013-04-18 10:24:44 EDT
Can this fix be backported for IES 422 ?
Comment 9 Daniel Rolka CLA 2013-04-29 08:04:17 EDT
Verified in the build I20130428-2000
Comment 10 Remy Suen CLA 2013-05-03 14:51:25 EDT
I have confirmed that the problem is gone on my end on 4.3M7. Thanks, Daniel and Paul!
Comment 11 Paul Webster CLA 2013-05-17 08:34:48 EDT
Another part of the fix we'll need to put in 4.3.1

http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?h=R4_2_maintenance&id=65406fd6c95cbd322b265ccc0ce761aa8bd4caeb

PW
Comment 12 Daniel Rolka CLA 2013-06-26 04:52:09 EDT
(In reply to comment #11)
> Another part of the fix we'll need to put in 4.3.1
> 
> http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/
> ?h=R4_2_maintenance&id=65406fd6c95cbd322b265ccc0ce761aa8bd4caeb
> 
> PW

Paul,

Can I close this bug or we have to verify it once again? If so, do you have any test scenario that can be used to check the last commit?

thanks,
Daniel
Comment 13 Paul Webster CLA 2013-07-04 13:39:03 EDT
The 2 commits have to be backported to 4.3.1

PW
Comment 14 Aniruddha Shevade CLA 2013-07-31 03:44:43 EDT
Hello
 Is there a work around for this? We are seeing this issue , which was working fine in earlier versions of eclipse. After upgrading to 4.3. I see the following exception when a popup menu is displayed. Is there a fix which can be downloaded for this to work, or when is the target date for the proposed fix.



Thanks
Ani


org.eclipse.emf.common.util.AbstractEList$BasicIndexOutOfBoundsException: index=2, size=1
	at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:332)
	at org.eclipse.e4.ui.workbench.renderers.swt.MenuManagerRenderer.reconcileManagerToModel(MenuManagerRenderer.java:859)
	at org.eclipse.e4.ui.workbench.renderers.swt.MenuManagerRenderer.reconcileManagerToModel(MenuManagerRenderer.java:860)
	at org.eclipse.ui.internal.PopupMenuExtender.addMenuContributions(PopupMenuExtender.java:414)
	at org.eclipse.ui.internal.PopupMenuExtender.menuAboutToShow(PopupMenuExtender.java:388)
	at org.eclipse.jface.action.MenuManager.fireAboutToShow(MenuManager.java:343)
	at org.eclipse.jface.action.MenuManager.handleAboutToShow(MenuManager.java:475)
	at org.eclipse.jface.action.MenuManager.access$1(MenuManager.java:470)
	at org.eclipse.jface.action.MenuManager$2.menuShown(MenuManager.java:500)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:255)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1057)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1081)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062)
	at org.eclipse.swt.widgets.Control.WM_INITMENUPOPUP(Control.java:4964)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4640)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:340)
	at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1627)
	at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:2075)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4977)
	at org.eclipse.swt.internal.win32.OS.TrackPopupMenu(Native Method)
	at org.eclipse.swt.widgets.Menu._setVisible(Menu.java:257)
	at org.eclipse.swt.widgets.Display.runPopups(Display.java:4211)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3753)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1113)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:138)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:610)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
c
Comment 15 Daniel Rolka CLA 2013-07-31 03:52:40 EDT
(In reply to comment #14)
> Hello
>  Is there a work around for this? We are seeing this issue , which was
> working fine in earlier versions of eclipse. After upgrading to 4.3. I see
> the following exception when a popup menu is displayed. Is there a fix which
> can be downloaded for this to work, or when is the target date for the
> proposed fix.
> 
> 
> 
> Thanks
> Ani
> 

Are you able to attach some simple test project where we can recreate the issue?

Daniel
Comment 16 Paul Webster CLA 2013-07-31 06:06:23 EDT
(In reply to comment #14)
> Hello
>  Is there a work around for this?

The only workaround is not to register a contained MenuManager after registering the parent MenuManager.

It's fixed in 4.4 and will be backported to 4.3.1

PW
Comment 17 Paul Webster CLA 2013-07-31 06:26:44 EDT
Paul, could you review this for 4.3.1? https://git.eclipse.org/r/#/c/15009/

PW
Comment 19 Aniruddha Shevade CLA 2013-07-31 17:24:30 EDT
(In reply to comment #16)

 Hi Paul
  In this case, I have registered my own ContextMenuProvider class  say 'myContextMenuProvider', which extends the org.eclipse.gef.ContextMenuProvider . 

This is registered in the configureGraphicalViewer() method using code as

    getGraphicalViewer().setContextMenu(myContextMenuProvider)

 ((IEditorSite) getSite()).registerContextMenu(  "myContextMenuId", 
				myContextMenuProvider, getGraphicalViewer(), false); 

I am not able to follow, which of these places would i do the workaround , and how? 


Would the backport for 4.3.1 be publicly available anytime soon

Thanks for all your help
AS




> (In reply to comment #14)
> > Hello
> >  Is there a work around for this?
> 
> The only workaround is not to register a contained MenuManager after
> registering the parent MenuManager.
> 
> It's fixed in 4.4 and will be backported to 4.3.1
> 
> PW
Comment 20 Paul Webster CLA 2013-08-01 08:33:31 EDT
(In reply to comment #19)
> 
> I am not able to follow, which of these places would i do the workaround ,
> and how? 

I'm not familiar with GEF, so I can't tell you where it's double-registering.

> Would the backport for 4.3.1 be publicly available anytime soon

Kepler SR1 will be available beginning of October.  But the fix will be in the next Maintenance (M) build on http://download.eclipse.org/eclipse/downloads/ sometime next Wednesday afternoon.

PW
Comment 21 Wim Jongman CLA 2013-08-05 06:16:41 EDT
(In reply to comment #20)
> (In reply to comment #19)
> > 
> > I am not able to follow, which of these places would i do the workaround ,
> > and how? 
> 
> I'm not familiar with GEF, so I can't tell you where it's double-registering.
> 
> > Would the backport for 4.3.1 be publicly available anytime soon
> 
> Kepler SR1 will be available beginning of October.  But the fix will be in
> the next Maintenance (M) build on
> http://download.eclipse.org/eclipse/downloads/ sometime next Wednesday
> afternoon.
> 
> PW

Will there be a juno 4.2.3? Since Rational tools have moved to Juno 4.2.2 this can cause some headaches for implementers.
Comment 22 Dani Megert CLA 2013-08-06 06:52:14 EDT
(In reply to comment #21)
> (In reply to comment #20)
> > (In reply to comment #19)
> > > 
> > > I am not able to follow, which of these places would i do the workaround ,
> > > and how? 
> > 
> > I'm not familiar with GEF, so I can't tell you where it's double-registering.
> > 
> > > Would the backport for 4.3.1 be publicly available anytime soon
> > 
> > Kepler SR1 will be available beginning of October.  But the fix will be in
> > the next Maintenance (M) build on
> > http://download.eclipse.org/eclipse/downloads/ sometime next Wednesday
> > afternoon.
> > 
> > PW
> 
> Will there be a juno 4.2.3? Since Rational tools have moved to Juno 4.2.2
> this can cause some headaches for implementers.

No there won't be a SR3. Rational can provide a fix(pack) if they desire to do so.
Comment 23 Daniel Rolka CLA 2013-08-29 04:31:35 EDT
Verified in the build: M20130828-0800