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

Bug 483807

Summary: Problem with InMemoryResourceImpl and IsModifiedSavingPolicy
Product: [Modeling] Sirius Reporter: Laurent Redor <laurent.redor>
Component: CoreAssignee: Esteban DUGUEPEROUX <esteban.dugueperoux>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: esteban.dugueperoux, florian.barbin, pierre-charles.david
Version: 3.1.0Keywords: triaged
Target Milestone: 4.0.0M5   
Hardware: All   
OS: All   
See Also: https://git.eclipse.org/r/64483
https://git.eclipse.org/r/64485
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=1c90b4a92fc288537c2df689afe243ad8ddbf2e8
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=97e94f0306b1ec1194f707d5bfd472e54d13f082
https://bugs.eclipse.org/bugs/show_bug.cgi?id=497559
Whiteboard:

Description Laurent Redor CLA 2015-12-07 10:04:47 EST
When a session is saved, the InMemoryResourceImpl resources of this session kept their isModified status to true.

A simple modification of TransientSessionTests reveals the problem:
diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/common/TransientSessionTests.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/common/TransientSessionTests.java
index 0354d80..f47be92 100644
--- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/common/TransientSessionTests.java
+++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/common/TransientSessionTests.java
@@ -132,6 +132,7 @@
         ISaveablePart saveablePart = diagramEditor;
         assertEquals("With a transient session adding a EClass should, the session become dirty ", SessionStatus.DIRTY, session.getStatus());
         assertTrue("With a transient session adding a EClass should, the editor become dirty ", saveablePart.isDirty());
+        assertTrue("The resource status is wrong for a transient session. It should be modified after modification.", session.getSessionResource().isModified());
 
         // Save on diagramEditor
         saveablePart.doSave(new NullProgressMonitor());
@@ -139,6 +140,7 @@
 
         assertEquals("With a transient session the save should be allowed", SessionStatus.SYNC, session.getStatus());
         assertFalse("With a transient session, saving the editor, it become no dirty ", saveablePart.isDirty());
+        assertFalse("The resource status is wrong for a transient session. It should be \"not modified\" after a save.", session.getSessionResource().isModified());
 
         DialectUIManager.INSTANCE.closeEditor(diagramEditor, true);
         TestsUtil.synchronizationWithUIThread();
Comment 1 Laurent Redor CLA 2015-12-07 10:07:19 EST
A idea of fix, will be to replace:
resourcetoSave.getURI().isFile() || resourcetoSave.getURI().isPlatformResource()
by
!ResourceSetSync.isReadOnly(resourcetoSave)
in
org.eclipse.sirius.business.internal.session.IsModifiedSavingPolicy.computeResourcesToSave(...).new Predicate() {...}.apply(Resource)
as it is done before.
Comment 2 Eclipse Genie CLA 2016-01-15 11:32:39 EST
New Gerrit change created: https://git.eclipse.org/r/64483
Comment 3 Eclipse Genie CLA 2016-01-15 11:33:41 EST
New Gerrit change created: https://git.eclipse.org/r/64485
Comment 4 Esteban DUGUEPEROUX CLA 2016-01-15 11:35:36 EST
Proposed fix and tests update has been pushed on Gerrit through 2 gerrits. see previous comments.
Comment 7 Esteban DUGUEPEROUX CLA 2016-01-18 08:46:17 EST
Fixed on master.
Comment 8 Florian Barbin CLA 2016-05-20 11:24:29 EDT
The test TransientSessionTests.testDiagramWithTransientSession passed on JUnit master
Comment 9 Pierre-Charles David CLA 2016-06-24 08:02:11 EDT
Available in Sirius 4.0.0.