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

Bug 458151

Summary: Unstability on resource reload
Product: [Modeling] Sirius Reporter: Belqassim Djafer <belqassim.djafer>
Component: CoreAssignee: Project inbox <sirius.core-inbox>
Status: CLOSED FIXED QA Contact: Belqassim Djafer <belqassim.djafer>
Severity: normal    
Priority: P3 CC: laurent.redor, pierre-charles.david, steve.monnier
Version: unspecifiedKeywords: triaged
Target Milestone: 3.0.0M6   
Hardware: PC   
OS: Windows 8   
Whiteboard:
Bug Depends on: 458721    
Bug Blocks:    
Attachments:
Description Flags
Unstability on session reload
none
Unstability on session reload
none
JUnit test corresponding to comment 3
none
JUnit test corresponding to comment 3 none

Description Belqassim Djafer CLA 2015-01-22 09:24:23 EST
Created attachment 250148 [details]
Unstability on session reload

Instabilities occur when reloading resources.

To reproduce : 
1- Extract and import the attached projects in the workspace.
2- Open "P0 representation" in the LoadResource project.
3- By using tools, create a new Container, BorderedNode and a new Reference between the created BorderedNode and "C4" BorderedNode.
4- Save the representation.
5- Open LoadResourceToPast project and copy My_P0.aird and My_P0.ecore files. Past them into LoadResource project (Click yes to replace files).
6- New created elements dispears from the representation -> OK. But also BorderedNodes are deleted and red crosses appears -> KO
Comment 1 Laurent Redor CLA 2015-01-23 11:33:24 EST
Created attachment 250189 [details]
Unstability on session reload

Replace the previous rar archive with a zip one
Comment 2 Laurent Redor CLA 2015-01-23 11:49:39 EST
For information, org.eclipse.sirius.diagram.ui.tools.internal.providers.decorators.EditModeDecorator.getDecorationImage(EditPart) "makes" the red crosses.
Comment 3 Laurent Redor CLA 2015-01-27 09:14:55 EST
The problem is linked to the fragment. I have created a junit test to isolate the problem: "EMFUnloadWithStrangeProxyURITests".

In this test, we can see that the test testURIAfterUnloadWithoutFragment() is OK but the test testURIAfterUnloadWithFragment() is KO.
There is several sysout in these tests that reveal that after unload, in case of fragment, the URI of the proxy is 
file:/pathToGit/org.eclipse.sirius/plugins/org.eclipse.sirius.tests.junit/B1.ecore#//b2.1/ClassB
instead of 
file:/pathToGit/org.eclipse.sirius/plugins/org.eclipse.sirius.tests.junit/B1.ecore#//b2/ClassB
Comment 4 Laurent Redor CLA 2015-01-27 09:15:45 EST
Created attachment 250265 [details]
JUnit test corresponding to comment 3
Comment 5 Laurent Redor CLA 2015-01-27 09:34:06 EST
Created attachment 250268 [details]
JUnit test corresponding to comment 3

New version of the JUnit test (simpler, more focused on the problem)
Comment 6 Laurent Redor CLA 2015-01-27 11:08:09 EST
I posted this [1] on EMF forum to have help on this bug

[1] https://www.eclipse.org/forums/index.php/t/967104/
Comment 7 Laurent Redor CLA 2015-01-28 10:54:41 EST
By adapting the JUnit test, I observed that the behavior is different if B1.ecore is a fragment of B.ecore or if B1.ecore is a "standalone" resource.

In case of B1.ecore as "standalone" resource, the behavior is OK. But if B1.ecore is a fragment, there is the mentioned bug.

The difference is in BasicEObjectImpl.eInternalResource(). In case of "standalone" resource, no resource is returned. And so the proxy is not resolved. But in case of fragment, the "parent" resource is returned, B.ecore, in our case. And this is sufficient to resolve the proxy and then have the problem.

	EPackageImpl(BasicEObjectImpl).eInternalResource() line: 939	
	EPackageImpl(BasicEObjectImpl).eResource() line: 920	
	EcoreUtil.resolve(EObject, EObject) line: 258	
	EPackageImpl(BasicEObjectImpl).eResolveProxy(InternalEObject) line: 1473	
	EObjectContainmentWithInverseEList$Resolving<E>(EcoreEList<E>).resolveProxy(EObject) line: 206	
	EObjectContainmentWithInverseEList$Resolving<E>(EcoreEList<E>).resolve(int, EObject) line: 161	
	EObjectContainmentWithInverseEList$Resolving<E>.resolve(int, E) line: 105	
	EObjectContainmentWithInverseEList$Resolving<E>(BasicEList<E>).get(int) line: 348	
	ENamedElementImpl$1$1(EContentsEList$FeatureIteratorImpl<E>).hasNext() line: 471	
	EPackageImpl(EModelElementImpl).eURIFragmentSegment(EStructuralFeature, EObject) line: 332	
	EcoreResourceFactoryImpl$1(ResourceImpl).getURIFragment(EObject) line: 680	
	EcoreResourceFactoryImpl$1(XMLResourceImpl).getURIFragment(EObject) line: 630	
	EcoreResourceFactoryImpl$1(ResourceImpl).unloaded(InternalEObject) line: 1594	
	EcoreResourceFactoryImpl$1(ResourceImpl).doUnload() line: 1655	
	EcoreResourceFactoryImpl$1(XMLResourceImpl).doUnload() line: 713	
	EcoreResourceFactoryImpl$1(ResourceImpl).unload() line: 1670	
	EMFUnloadWithStrangeProxyURITests.init(boolean) line: 114	
	EMFUnloadWithStrangeProxyURITests.testURIAfterUnloadWithFragment() line: 51
Comment 8 Laurent Redor CLA 2015-03-12 10:24:39 EDT
Work interrupted: Waiting news about bug 458721
Comment 9 Laurent Redor CLA 2015-03-23 06:09:09 EDT
The fix proposed by Ed in bug 458721 fix the problem.
Comment 10 Laurent Redor CLA 2015-03-23 10:36:44 EDT
The problem is solved by bug 458721 (it will be available only on Mars TP).
Comment 11 Belqassim Djafer CLA 2015-04-13 09:20:09 EDT
KO on Sirius 3.0.0M6

Because the proposed fix in bug 458721 in not included in Eclipse Mars
Comment 12 Belqassim Djafer CLA 2015-05-22 03:31:16 EDT
Verified with Sirius 3.0.0 RC1
Comment 13 Pierre-Charles David CLA 2015-06-24 11:17:30 EDT
Available in Sirius 3.0.0. See https://wiki.eclipse.org/Sirius/3.0.0.