epsilon icon indicating copy to clipboard operation
epsilon copied to clipboard

Cached EMF resources not disposed correctly

Open kolovos opened this issue 2 years ago • 4 comments

After the following ANT build file

<project default="main">
	<target name="main">
		<epsilon.emf.loadModel name="M1" modelfile="m1.ecore" metamodeluri="http://www.eclipse.org/emf/2002/Ecore" read="true" store="false"/>
		<epsilon.emf.loadModel name="M2" modelfile="m2.ecore" metamodeluri="http://www.eclipse.org/emf/2002/Ecore" read="true" store="false"/>

		<epsilon.eol>
			M1!EClass.all.first().eSuperTypes.println();
			M2!EClass.all.first().eSuperTypes.println();
			<model ref="M1"/>
			<model ref="M2"/>
		</epsilon.eol>

	</target>
</project>

is executed against the following models m1.ecore and m2.ecore that reference each other, the models are not disposed properly. As a result, if we re-execute the same build file in the same JVM, the contents of m2.ecore are not loaded from disk the second time.

<?xml version="1.0" encoding="ASCII"?>
<ecore:EClass xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmi:id="_rnSosFwLEe2eQLwPX_T8WQ" name="C11">
  <eSuperTypes href="m2.ecore#/"/>
</ecore:EClass>
<?xml version="1.0" encoding="ASCII"?>
<ecore:EClass xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmi:id="_sBzacFwLEe2eQLwPX_T8WQ" name="C221">
  <eSuperTypes href="m1.ecore#/"/>
</ecore:EClass>

A workaround for this is to add the following JavaScript task to the build file to clear the EMF driver's resource cache.

<script language="javascript">
with(new JavaImporter(org.eclipse.epsilon.emc.emf)){
  CachedResourceSet.getCache().clear();
}
</script>

kolovos avatar Nov 04 '22 07:11 kolovos