Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 486635

Summary: Exception logged after cancelling Editor Selection dialog
Product: [Eclipse Project] Platform Reporter: Noopur Gupta <noopur_gupta>
Component: UIAssignee: Dani Megert <daniel_megert>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, loskutov, markus.kell.r
Version: 4.6   
Target Milestone: 4.6 M5   
Hardware: All   
OS: All   
See Also: https://git.eclipse.org/r/65253
Whiteboard:
Bug Depends on: 90292    
Bug Blocks:    

Description Noopur Gupta CLA 2016-01-27 06:09:41 EST
4.6 I20160126-0800.

- Open a new workspace, create a Java project and create a file named "test.zz" in that.
- Go to File Association preferences and select "Ask via pop-up" for opening unknown files.
- Right-click on the file in Package explorer, click Open With > Default Editor. The Editor Selection dialog comes up.
- Press Cancel on the dialog.

=> Exception is logged in the Error log view:

org.eclipse.ui
Error
Wed Jan 27 16:34:28 IST 2016
Unhandled event loop exception

org.eclipse.core.runtime.OperationCanceledException: No editor selected, operation canceled by user.
	at org.eclipse.ui.internal.ide.AskUserViaPopupUnknownEditorStrategy.getEditorDescriptor(AskUserViaPopupUnknownEditorStrategy.java:36)
	at org.eclipse.ui.ide.IDE.getEditorDescriptor(IDE.java:1016)
	at org.eclipse.ui.ide.IDE.getEditorDescriptor(IDE.java:733)
	at org.eclipse.ui.ide.IDE.getEditorDescriptor(IDE.java:688)
	at org.eclipse.ui.actions.OpenWithMenu.lambda$2(OpenWithMenu.java:352)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4373)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1081)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4191)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3779)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1118)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1019)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:157)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:691)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:604)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:138)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:670)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:609)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1516)
Comment 1 Dani Megert CLA 2016-01-27 07:28:44 EST
Would be good to have a fix today since it's a new feature advertised in the N&N.
Comment 2 Eclipse Genie CLA 2016-01-27 07:37:49 EST
New Gerrit change created: https://git.eclipse.org/r/65253
Comment 3 Andrey Loskutov CLA 2016-01-27 08:22:24 EST
(In reply to Dani Megert from comment #1)
> Would be good to have a fix today since it's a new feature advertised in the
> N&N.

(In reply to Eclipse Genie from comment #2)
> New Gerrit change created: https://git.eclipse.org/r/65253

Dani, should I directly merge the fix or do you want to review it first?
Comment 4 Dani Megert CLA 2016-01-27 08:24:54 EST
(In reply to Andrey Loskutov from comment #3)
> (In reply to Dani Megert from comment #1)
> > Would be good to have a fix today since it's a new feature advertised in the
> > N&N.
> 
> (In reply to Eclipse Genie from comment #2)
> > New Gerrit change created: https://git.eclipse.org/r/65253
> 
> Dani, should I directly merge the fix or do you want to review it first?

Just reviewed it. The fix is not good.
Comment 5 Andrey Loskutov CLA 2016-01-27 08:36:51 EST
(In reply to Dani Megert from comment #4)
> (In reply to Andrey Loskutov from comment #3)
> > (In reply to Dani Megert from comment #1)
> > > Would be good to have a fix today since it's a new feature advertised in the
> > > N&N.
> > 
> > (In reply to Eclipse Genie from comment #2)
> > > New Gerrit change created: https://git.eclipse.org/r/65253
> > 
> > Dani, should I directly merge the fix or do you want to review it first?
> 
> Just reviewed it. The fix is not good.

I've just pushed a second attempt. The problem is that IDE.open*() methods must return something, so we can't handle cancellation there.
Comment 6 Andrey Loskutov CLA 2016-01-27 08:52:55 EST
After discussion on the patch I don't see a way to fix this issue without changing IDE.open*() semantics, so returning this one back to the team pool.
Comment 7 Dani Megert CLA 2016-01-27 10:23:17 EST
(In reply to Andrey Loskutov from comment #6)
> After discussion on the patch I don't see a way to fix this issue without
> changing IDE.open*() semantics, so returning this one back to the team pool.

Argh, this is nasty! #openEditor is not the issue, but #getEditorDescriptor which does not allow 'null'. This makes a clean fix impossible and we will have to live with the OperationCanceledException and catch the cases we know about.

We should catch the exception in the #openEditor methods and then return 'null' (no one does - or could do - anything useful with 'null'). This would shield most clients (e.g. catch in OpenAndLinkWithEditorHelper would not be needed), except for those who call #getEditorDescriptor, like e.g. the OpenWithMenu.

And we need document the new exception in all #getEditorDescriptor API methods.

Andrey, what do you think? Would you be able to provide a patch along these lines?
Comment 8 Andrey Loskutov CLA 2016-01-27 10:28:00 EST
(In reply to Dani Megert from comment #7)
> Andrey, what do you think? Would you be able to provide a patch along these
> lines?

Yes, but not today anymore, may be for M6?
Comment 9 Dani Megert CLA 2016-01-27 11:36:44 EST
(In reply to Andrey Loskutov from comment #8)
> (In reply to Dani Megert from comment #7)
> > Andrey, what do you think? Would you be able to provide a patch along these
> > lines?
> 
> Yes, but not today anymore, may be for M6?

This is new functionality with new "API" throwing the exception.

I've fixed it with http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=b5b43711fef1645eb643ddffc40b851b6325750f

Filed bug 486665 to check all callers of #getEditorDescription.
Comment 10 Markus Keller CLA 2016-01-27 12:59:51 EST
(In reply to Dani Megert from comment #9)
Changes look good, but the whole feature is breaking APIs, see bug 486665 comment 1.