Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 312501 - Same resource twice in ResourceSet of a XtextResource
Summary: Same resource twice in ResourceSet of a XtextResource
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: RC1   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-11 16:11 EDT by Marco CLA
Modified: 2017-09-19 16:28 EDT (History)
3 users (show)

See Also:
sebastian.zarnekow: helios+


Attachments
SynchronizedXtextResourceSet + Test (18.10 KB, patch)
2010-05-14 05:40 EDT, Sebastian Zarnekow CLA
sebastian.zarnekow: review+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Marco CLA 2010-05-11 16:11:42 EDT
Build Identifier: 201005101939

After a clean build a the ResourceSet of the XtextResource of a resource in the editor includes one LazyLinker to itself and two LazyLinkers to the same resource of which objects are referenced by this resource.

I think this should not be the case, and it causes other problems.

I use "org.eclipse.xtext.generator.scoping.ImportNamespacesScopingFragment" to generate the plugin.

br,
Marco

Reproducible: Always
Comment 1 Marco CLA 2010-05-11 16:12:17 EDT
I think it was not the case in builds a week ago.
Comment 2 Sebastian Zarnekow CLA 2010-05-12 03:06:07 EDT
Hi Marco,

I'm afraid I did not understand the problem. Could you provide a testcase that illustrates the issue?

Regards,
Sebastian
Comment 3 Marco CLA 2010-05-12 11:24:51 EDT
I am afraid, I can't provide a test case. I don't know how to extract the relevant parts from my project which I cannot publish as is. Aslo my model is too big and complex to cut it down.

I try to describe what might be done to reproduce. I guess you have more pieces to reuse for it.

- Meta model with references
- org.eclipse.xtext.generator.scoping.ImportNamespacesScopingFragment
- model resource with resolved reference to object of other resource, without import statement (just implicitely due to the fact that other resource is in same folder)
- outline menu to trigger custom code which shows ResourceSet of the current Resource
- check whether same resource is included twice in the ResourceSet referenced via different LazyLinkers.

If you have any idea what could have caused this I will try to check.

br
m
Comment 4 Sebastian Zarnekow CLA 2010-05-12 11:27:46 EDT
Hi Marco,

so you are experiences duplicate resources (Resources with the very same URI) in resourceSet.getResources()

Regards,
Sebastian
Comment 5 Sebastian Zarnekow CLA 2010-05-12 11:32:02 EDT
If this is the case, it may be caused by concurrent read operations on the model. The outline and the validator use read-locks but both try to resolve proxies. This is actually a modify operation on the resourceSet so in case both try to resolve a proxy to the very same resource concurrently, the resource may be added twice to the resourceSet. We marked Resource#getEObject(fragment) already as synchronized due to this behaviour. I'm afraid something similar has to be done for ResourceSet#getResource() so there may be the requirement to use exclusive read operations or the proxy resolution has to be performed upfront which will have a serious impact on the performance of any application that does not need to resolve proxies to display the outline.
Comment 6 Marco CLA 2010-05-12 11:43:22 EDT
I do not build Xtext myself but just use the nightly builds. Is there a way in which I can still check your assumption?

To keep performance, wouldn't it be an option to temporarily allow such duplicate entries during building/loading an clean the ResourceSets immediately afterwards?

br
m
Comment 7 Sebastian Zarnekow CLA 2010-05-12 11:45:57 EDT
So I understood you correctly that two resources with the very same uri are added twice to your resourceset?
Comment 8 Marco CLA 2010-05-12 11:56:32 EDT
yes
Comment 9 Sebastian Zarnekow CLA 2010-05-14 05:40:54 EDT
Created attachment 168518 [details]
SynchronizedXtextResourceSet + Test

We were able to reproduce the concurrency issues. The patch contains a SynchronizedXtextResourceSet and a test that illustrates the problem with concurrently resolved proxies.
I'ld like to provide another test that uses the XtextDocument API with concurrent readOnly() operations that resolve proxies and reveal this problem.
Comment 10 Sebastian Zarnekow CLA 2010-05-14 06:21:34 EDT
Fixed in HEAD.
Comment 11 Moritz Eysholdt CLA 2010-05-15 06:34:05 EDT
Now both Xtext and MWE2 try to configure their own ResourceSet. This collides, as reported by Joerg Reichert.

See
org.eclipse.emf.mwe2.language.Mwe2RuntimeModule.provideXtextResourceSet()
and
org.eclipse.xtext.service.DefaultRuntimeModule.bindXtextResourceSet()


16   [main] ERROR org.eclipse.emf.mwe2.language.ui.internal.Mwe2Activator  - Guice creation errors:

1) A binding to org.eclipse.xtext.resource.XtextResourceSet was already configured at org.eclipse.xtext.service.ProviderModule.configure(ProviderModule.java:40).
  at org.eclipse.xtext.service.BindModule.configure(BindModule.java:36)

1 error
com.google.inject.CreationException: Guice creation errors:

1) A binding to org.eclipse.xtext.resource.XtextResourceSet was already configured at org.eclipse.xtext.service.ProviderModule.configure(ProviderModule.java:40).
  at org.eclipse.xtext.service.BindModule.configure(BindModule.java:36)

1 error
	at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:354)
	at com.google.inject.InjectorBuilder.initializeStatically(InjectorBuilder.java:152)
	at com.google.inject.InjectorBuilder.build(InjectorBuilder.java:105)
	at com.google.inject.Guice.createInjector(Guice.java:92)
	at com.google.inject.Guice.createInjector(Guice.java:69)
	at com.google.inject.Guice.createInjector(Guice.java:59)
	at org.eclipse.emf.mwe2.language.ui.internal.Mwe2Activator.start(Mwe2Activator.java:38)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:783)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:774)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:755)
	at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:370)
	at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:284)
	at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:417)
	at org.eclipse.osgi.internal.loader.BundleLoader.setLazyTrigger(BundleLoader.java:265)
	at org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:106)
	at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:453)
	at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:216)
	at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:393)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:469)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
	at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at org.eclipse.osgi.internal.loader.BundleLoader.loadClass(BundleLoader.java:338)
	at org.eclipse.osgi.framework.internal.core.BundleHost.loadClass(BundleHost.java:232)
	at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadClass(AbstractBundle.java:1197)
	at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:174)
	at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:904)
	at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)
	at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:55)
	at org.eclipse.ui.internal.WorkbenchPlugin$1.run(WorkbenchPlugin.java:266)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.ui.internal.WorkbenchPlugin.createExtension(WorkbenchPlugin.java:262)
	at org.eclipse.ui.internal.registry.EditorDescriptor.createEditor(EditorDescriptor.java:235)
	at org.eclipse.ui.internal.EditorManager.createPart(EditorManager.java:845)
	at org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReference.java:609)
	at org.eclipse.ui.internal.EditorReference.createPart(EditorReference.java:465)
	at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:595)
	at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:313)
	at org.eclipse.ui.internal.presentations.PresentablePart.setVisible(PresentablePart.java:180)
	at org.eclipse.ui.internal.presentations.util.PresentablePartFolder.select(PresentablePartFolder.java:270)
	at org.eclipse.ui.internal.presentations.util.LeftToRightTabOrder.select(LeftToRightTabOrder.java:65)
	at org.eclipse.ui.internal.presentations.util.TabbedStackPresentation.selectPart(TabbedStackPresentation.java:473)
	at org.eclipse.ui.internal.PartStack.refreshPresentationSelection(PartStack.java:1254)
	at org.eclipse.ui.internal.PartStack.setSelection(PartStack.java:1207)
	at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:1606)
	at org.eclipse.ui.internal.PartStack.add(PartStack.java:497)
	at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:103)
	at org.eclipse.ui.internal.PartStack.add(PartStack.java:483)
	at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:112)
	at org.eclipse.ui.internal.EditorSashContainer.addEditor(EditorSashContainer.java:63)
	at org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorAreaHelper.java:225)
	at org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAreaHelper.java:213)
	at org.eclipse.ui.internal.EditorManager.createEditorTab(EditorManager.java:778)
	at org.eclipse.ui.internal.EditorManager.openEditorFromDescriptor(EditorManager.java:677)
	at org.eclipse.ui.internal.EditorManager.openEditor(EditorManager.java:638)
	at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched(WorkbenchPage.java:2860)
	at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:2768)
	at org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPage.java:2760)
	at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.java:2711)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2707)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2691)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2682)
	at org.eclipse.ui.ide.IDE.openEditor(IDE.java:651)
	at org.eclipse.ui.ide.IDE.openEditor(IDE.java:610)
	at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInEditor(EditorUtility.java:365)
	at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInEditor(EditorUtility.java:168)
	at org.eclipse.jdt.ui.actions.OpenAction.run(OpenAction.java:229)
	at org.eclipse.jdt.ui.actions.OpenAction.run(OpenAction.java:208)
	at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:274)
	at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:250)
	at org.eclipse.jdt.internal.ui.packageview.PackageExplorerActionGroup.handleOpen(PackageExplorerActionGroup.java:373)
	at org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart$4.open(PackageExplorerPart.java:526)
	at org.eclipse.ui.OpenAndLinkWithEditorHelper$InternalListener.open(OpenAndLinkWithEditorHelper.java:48)
	at org.eclipse.jface.viewers.StructuredViewer$2.run(StructuredViewer.java:845)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49)
	at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
	at org.eclipse.jface.viewers.StructuredViewer.fireOpen(StructuredViewer.java:843)
	at org.eclipse.jface.viewers.StructuredViewer.handleOpen(StructuredViewer.java:1131)
	at org.eclipse.jface.viewers.StructuredViewer$6.handleOpen(StructuredViewer.java:1235)
	at org.eclipse.jface.util.OpenStrategy.fireOpenEvent(OpenStrategy.java:264)
	at org.eclipse.jface.util.OpenStrategy.access$2(OpenStrategy.java:258)
	at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:298)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1052)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2601)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2565)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2399)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:669)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:662)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1383)
Comment 12 Sebastian Zarnekow CLA 2010-05-15 15:02:09 EDT
Fixed in commit
http://git.softeys.de/emf.mwe.git/commit/e322a71c40ecd804a653594a1f9be3167154756d

Please verify that it does not happen with MWE2 HEAD.
Comment 13 Karsten Thoms CLA 2017-09-19 16:28:47 EDT
Closing bug which were set to RESOLVED before Eclipse Neon.0.