Bug 496355 - Wrong Application.e4xmi produce inappropriate exception messages
Summary: Wrong Application.e4xmi produce inappropriate exception messages
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.6   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: bugday, helpwanted
Depends on:
Blocks:
 
Reported: 2016-06-19 12:43 EDT by Janko Diminic CLA
Modified: 2017-07-19 16:58 EDT (History)
3 users (show)

See Also:


Attachments
Wrong and correnct command/handler position in Application.e4xmi file. (32.24 KB, image/png)
2016-06-19 12:43 EDT, Janko Diminic CLA
no flags Details
Demo application (14.12 KB, application/zip)
2016-07-21 15:48 EDT, Philip Wenig CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Janko Diminic CLA 2016-06-19 12:43:38 EDT
Created attachment 262526 [details]
Wrong and correnct command/handler position in Application.e4xmi file.

When I create wrong Application.e4xmi file, respectively incorrectly position of Handler and Command in wrong Model Fragment I get a exception that not contain appropriate exception message.

!ENTRY org.eclipse.osgi 4 0 2016-06-19 18:02:54.614
!MESSAGE Application error
!STACK 1
java.lang.ArrayStoreException: org.eclipse.e4.ui.model.application.commands.impl.HandlerImpl
	at org.eclipse.emf.common.util.BasicEList.assign(BasicEList.java:118)
	at org.eclipse.emf.common.util.BasicEList.addUnique(BasicEList.java:418)
	at org.eclipse.emf.common.notify.impl.NotifyingListImpl.doAddUnique(NotifyingListImpl.java:325)
	at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUnique(NotifyingListImpl.java:309)
	at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:303)
	at org.eclipse.e4.ui.model.internal.ModelUtils.mergeList(ModelUtils.java:197)
	at org.eclipse.e4.ui.model.internal.ModelUtils.merge(ModelUtils.java:145)
	at org.eclipse.e4.ui.model.fragment.impl.StringModelFragmentImpl.mergeIdList(StringModelFragmentImpl.java:322)
	at org.eclipse.e4.ui.model.fragment.impl.StringModelFragmentImpl.merge(StringModelFragmentImpl.java:300)
	at org.eclipse.e4.ui.internal.workbench.ModelAssembler.processFragment(ModelAssembler.java:192)
	at org.eclipse.e4.ui.internal.workbench.ModelAssembler.processFragments(ModelAssembler.java:103)
	at org.eclipse.e4.ui.internal.workbench.ModelAssembler.processModel(ModelAssembler.java:83)
	at org.eclipse.e4.ui.internal.workbench.ResourceHandler.loadMostRecentModel(ResourceHandler.java:259)
	at org.eclipse.e4.ui.internal.workbench.swt.E4Application.loadApplicationModel(E4Application.java:397)
	at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createE4Workbench(E4Application.java:254)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:628)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:606)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at org.eclipse.chemclipse.rcp.app.ui.internal.support.ApplicationSupport.startGraphicalContext(ApplicationSupport.java:118)
	at org.eclipse.chemclipse.rcp.app.ui.internal.support.ApplicationSupport.start(ApplicationSupport.java:92)
	at org.eclipse.chemclipse.rcp.app.ui.Application.start(Application.java:34)
	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:380)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1515)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1488)
Comment 1 Philip Wenig CLA 2016-07-21 15:48:11 EDT
Created attachment 263250 [details]
Demo application

I've created a demo application to test this bug.
Comment 2 Philip Wenig CLA 2016-07-22 02:43:30 EDT
I've also created a Git repo to better understand the bug:
https://github.com/OpenChrom/Eclipse-Bug496355

master -> application works
demo_fails -> application fails (see fragment.e4xmi)
Comment 3 Erdal Karaca CLA 2017-07-10 09:23:00 EDT
I think the error message is OK.
The tooling should not allow to add objects into inappropriate target lists (for example, a handler into a commands list).
Or at least there should be a validation error in the fragments editor.
Comment 4 Lars Vogel CLA 2017-07-10 11:01:33 EDT
(In reply to Erdal Karaca from comment #3)
> Or at least there should be a validation error in the fragments editor.

Patches welcome for adding this validation error
Comment 5 Erdal Karaca CLA 2017-07-17 12:38:32 EDT
In the meantime, the model editor does not allow to add an inappropriate element to a target list by accident.

This bug may be triggered if the XMI resource is manually edited in a text editor or the like.

But as of Oxygen, it is not reproducible anymore when using the model editor.

I think it has been fixed as of Bug 509464.
Comment 6 Erdal Karaca CLA 2017-07-19 04:46:45 EDT
Just realized that this inconsistent state can be triggered via drag and drop as well. I.e. drag and drop operations of the model adapter for a consitent behavior.

(In reply to Erdal Karaca from comment #5)
> In the meantime, the model editor does not allow to add an inappropriate
> element to a target list by accident.
> 
> This bug may be triggered if the XMI resource is manually edited in a text
> editor or the like.
> 
> But as of Oxygen, it is not reproducible anymore when using the model editor.
> 
> I think it has been fixed as of Bug 509464.
Comment 7 Erdal Karaca CLA 2017-07-19 04:48:20 EDT
My last sentence should read:

I.e. drag and drop operations of the model editor should also be adapted/enhanced for a consistent behavior.

(In reply to Erdal Karaca from comment #6)
> Just realized that this inconsistent state can be triggered via drag and
> drop as well. I.e. drag and drop operations of the model adapter for a
> consitent behavior.
> 
> (In reply to Erdal Karaca from comment #5)
> > In the meantime, the model editor does not allow to add an inappropriate
> > element to a target list by accident.
> > 
> > This bug may be triggered if the XMI resource is manually edited in a text
> > editor or the like.
> > 
> > But as of Oxygen, it is not reproducible anymore when using the model editor.
> > 
> > I think it has been fixed as of Bug 509464.
Comment 8 Lars Vogel CLA 2017-07-19 04:55:06 EDT
Erdal, could you provide a patch?
Comment 9 Erdal Karaca CLA 2017-07-19 16:58:06 EDT
I am trying... there is some duplicated code within copy+paste and drag+drop. I think the lack of syncing both aspects makes the model editor behave indeterministic: DND sometimes allows invalid operations and sometimes not.

(In reply to Lars Vogel from comment #8)
> Erdal, could you provide a patch?