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

Bug 510928

Summary: Improper unload of in-memory resources
Product: [Modeling] Sirius Reporter: Laurent Fasani <laurent.fasani>
Component: CoreAssignee: Pierre-Charles David <pierre-charles.david>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: florian.barbin, julien.dupont, pierre-charles.david, william.piers
Version: 4.1.1Keywords: triaged
Target Milestone: 5.1.0   
Hardware: All   
OS: All   
See Also: https://git.eclipse.org/r/103440
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=82112831e1d5f557b444e9e8b9be7baed927ce58
Whiteboard:
Bug Depends on: 510893    
Bug Blocks: 521236    

Description Laurent Fasani CLA 2017-01-24 05:09:05 EST
+++ This bug was initially created as a clone of Bug #510893 +++

Since  https://github.com/pcdavid/org.eclipse.sirius/commit/de35505b28c6c6f5d583f3616950708e36b02b73 optimization, in-memory resources are inproperly loaded.

In
https://github.com/pcdavid/org.eclipse.sirius/blob/master/plugins/org.eclipse.sirius/src/org/eclipse/sirius/tools/internal/resource/InMemoryResourceImpl.java

the unload calls
   protected void doUnload() {
        super.doUnload();
        URI uri = getURI();
        InMemoryResourceFactoryImpl.IN_MEMORY_BUFFERS.remove(uri);
    }

If the uri is not removed, then the cache returns old closed sessions resources.
Comment 1 Laurent Fasani CLA 2017-01-24 05:23:35 EST
The code InMemoryResourceFactoryImpl.IN_MEMORY_BUFFERS.remove(uri); should not be done in unload method anymore.
It is similar to if XMIResource was deleted from the disk at unload.

To find a global and pertinent solution, let's understand that IN_MEMORY_BUFFERS is used to implement org.eclipse.sirius.tools.internal.resource.InMemoryURIConverterImpl.exists(URI, Map<?, ?>) that is used in DASI sub classes.

This bug is also related to Bug 469161
Comment 2 Pierre-Charles David CLA 2017-04-21 04:25:31 EDT
The initial plan was to partially rewrite the InMemoryResource code, as it does a lot of strange/non-standard things, but given the time left for 5.0, we'll only report the specific fix that was done on v4.1.x. I'll create a separate ticket for later (maybe 5.1) to review this code more completely.
Comment 3 Eclipse Genie CLA 2017-08-22 05:45:41 EDT
New Gerrit change created: https://git.eclipse.org/r/103440
Comment 4 Pierre-Charles David CLA 2017-08-22 05:56:42 EDT
(In reply to Pierre-Charles David from comment #2)
> I'll create a
> separate ticket for later (maybe 5.1) to review this code more completely.

See but #521237.
Comment 6 Pierre-Charles David CLA 2017-08-22 09:29:52 EDT
Fixed by 82112831e1d5f557b444e9e8b9be7baed927ce58.
Comment 7 Julien Dupont CLA 2017-09-20 05:58:15 EDT
Can not be verified: missing or incomplete reproduction information.
Comment 8 Pierre-Charles David CLA 2017-09-22 04:11:48 EDT
Closing as verified, as this is a cherry-pick of the change made in #510893 which could only be reproduced in a product-specific context and had been validated by the original reporter.
Comment 9 Pierre-Charles David CLA 2017-11-08 03:37:44 EST
Available in Sirius 5.1.0, see https://wiki.eclipse.org/Sirius/5.1.0.