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

Bug 488478

Summary: [Model] CCE from ModelService.getContainer()
Product: [Eclipse Project] Platform Reporter: Alexandra Buzila <abuzila>
Component: UIAssignee: Jonas Helming <jhelming>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: bsd, jhelming, tom.schindl
Version: 4.6   
Target Milestone: ---   
Hardware: PC   
OS: Windows NT   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=475934
Whiteboard: stalebug

Description Alexandra Buzila CLA 2016-02-25 10:27:56 EST
MUIElements can have containers that are not MUIElements themselves (e.g. model fragments). However, when calling the getContainer() method of the EModelService, the container is cast without a check to MUIElement, throwing a CCE.

Caused by: java.lang.ClassCastException: org.eclipse.e4.ui.model.fragment.impl.ModelFragmentsImpl cannot be cast to org.eclipse.e4.ui.model.application.ui.MUIElement
	at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.getContainer(ModelServiceImpl.java:850)
Comment 1 Alexandra Buzila CLA 2016-02-25 10:58:04 EST
Changing the return type of the getContainer() method would be an API change.
Comment 2 Thomas Schindl CLA 2016-02-25 14:48:58 EST
But how can that happen. All model elements in your running applicatiom should never be contained in a fragment?
Comment 3 Jonas Helming CLA 2016-02-26 03:22:31 EST
It happened because of Bug 475934
As this is fixed, it will hopefully not happen again for this case.
However, anyone could manually call getContainer with an element, which is not contained in an MUIElement for whatever reason. I agree that is not a typical case, but you could.

The question is, whether we want to just accept, that there is a CCE in this case, if we want to throw another exception or if we want to return null in this case.
Comment 4 Eclipse Genie CLA 2020-06-07 17:40:19 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.