Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Today's Messages (on)  | Unanswered Messages (off)

Forum: Hudson
 Topic: Accessing Google APIs from plugins?
Re: Accessing Google APIs from plugins? [message #1518247 is a reply to message #1517756] Sat, 20 December 2014 01:11
Kaz Nishimura is currently offline Kaz NishimuraFriend
Messages: 15
Registered: December 2014
Junior Member
Can I use that groupId for my artifacts?
Forum: Remote Application Platform (RAP)
 Topic: label horizontal separator color
label horizontal separator color [message #1518278] Sat, 20 December 2014 01:38
Song David is currently offline Song DavidFriend
Messages: 191
Registered: April 2011
Senior Member
hi,
in the online Developer's Guide for RAP 2.3, I found all about the separator css, but how to change the color of label horizontal separator color?
index.php/fa/20263/0/

Thanks for any help.

David
Forum: Java Development Tools (JDT)
 Topic: @NonNullByDefault Questions
@NonNullByDefault Questions [message #1518297] Sat, 20 December 2014 01:52
Chris Hubick is currently offline Chris HubickFriend
Messages: 2
Registered: July 2009
Junior Member
When the @NonNullByDefault Javadoc says:

Quote:
Note: Since org.eclipse.jdt.annotation 2.0.0, this annotation also applies to field and local variable declarations


Does it really mean to say something more like:

Quote:
Note: Since org.eclipse.jdt.annotation 2.0.0, this annotation may also be used to annotate field and local variable declarations


?

I'm asking because I was initially reading that sentence as saying any local variables would actually be considered non-null by default, so I'm then confused by even a simple test case...

import org.eclipse.jdt.annotation.*;

@NonNullByDefault
public class Test {

  public static final String test() {
    final String s = "test".intern();
    return s; // Why do I get a warning here "Null type safety: The expression of type 'String' needs unchecked conversion to conform to '@NonNull String'"?
  }

}


Now, if I remove the intern() call, the warning on the return disappears, which leads me to believe the nullability of s is determined by some inferencing, which wouldn't be needed if it were actually affected by the @NonNullByDefault?

Thanks!

[Updated on: Sat, 20 December 2014 05:31]

Report message to a moderator

Re: @NonNullByDefault Questions [message #1518553 is a reply to message #1518297] Sat, 20 December 2014 05:20
Chris Hubick is currently offline Chris HubickFriend
Messages: 2
Registered: July 2009
Junior Member
My other question relates to the Javadoc for org.eclipse.jdt.annotation.DefaultLocation, which first says:

Quote:
Wildcards and the use of type variables are always excluded from @NonNullByDefault


But then TYPE_BOUND goes on to provide an example:

@NonNullByDefault(TYPE_BOUND)
 interface X {
     <T extends Number> void process(T t, List<? super Number> l);
 }


Which says:

Quote:
Here both occurrences of Number will be interpreted as @NonNull Number.


So, the first occurrence is straightforward enough, but the second is a little confusing, given the previous statement about wildcards.

Is this saying that if it were simply List<?>, instead of List<? super Number>, then the contents could be null? Should the original statement be qualified to something like "unbounded wildcards"?

Thanks!
 Topic: Linked list Performance issues
Re: Linked list Performance issues [message #1518796 is a reply to message #1516551] Sat, 20 December 2014 08:43
Daniel Rigby is currently offline Daniel RigbyFriend
Messages: 2
Registered: December 2014
Junior Member
Anyone know why this is the case? On an intel machine and windows i believe the code shows that linked lists are faster and my implementation is slightly faster than the template version,

In theory linked list should be faster since it only needs to access an address pointer compared to finding the address of the array then doing arithmetic to calculate the element of the array to be accessed.
Forum: Oomph
 Topic: Can't build oomph
Re: Can't build oomph [message #1518509 is a reply to message #1517717] Sat, 20 December 2014 04:47
Eike Stepper is currently offline Eike StepperFriend
Messages: 5590
Registered: July 2009
Senior Member
Hi Markus,

I'm afraid I can only use Maven if it's working. I'm really not a Maven expert and we've never had problems like yours.
We call Maven locally with these parameters:

-Dbuild.id=Unknown
-Dgit.commit=Unknown
-Dgit.branch=Unknown
-DskipTests=true
-Denv=win64
clean
verify

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Am 19.12.2014 um 18:57 schrieb Markus Oley:
> Hi,
> I wanted to build oomph and therefore cloned the repository, checked out on master branch and called mvn compile, but
> I get the following error:
> Failed to execute goal org.eclipse.tycho:tycho-packaging-plugin:0.21.0:build-qualifier-aggregator
> (default-build-qualifier-aggregator) on project org.eclipse.oomph.gitbash: Execution
> default-build-qualifier-aggregator of goal org.eclipse.tycho:tycho-packaging-plugin:0.21.0:build-qualifier-aggregator
> failed: Project org.eclipse.oomph:org.eclipse.oomph.gitbash:eclipse-plugin:1.0.0-SNAPSHOT does not have expanded
> version -> [Help 1]
>
> Can you please tell me what I am doing wrong?
> Thanks in advacne
>
> Cheers
> Markus
 Topic: Import project formatter profile
Re: Import project formatter profile [message #1518889 is a reply to message #1517496] Sat, 20 December 2014 09:57
Ed Merks is currently offline Ed MerksFriend
Messages: 26285
Registered: July 2009
Senior Member
Eric,

We make heavy use of this in Oomph itself, e.g., automated cleanup
actions, including formatting, whenever we save and that does work well,
even if the preference does say "unmanaged profile". This is purely
driven from project specific settings.




On 19/12/2014 3:42 PM, Eric Rizzo wrote:
> Christian,
> I was excited to see that those formatter settings are stored in the
> project, but it doesn't appear to work. I imported the
> org.eclipse.papyrus.infra.core plugin project into my workspace, noted
> that it refers to a formatter profile ("Papyrus") that doesn't exist
> in my workspace. So I edited one of the files, moved the opening curly
> brace to a new line which is against what the project settings show me
> (the project settings indicate that all opening braces are to be on
> the same line). But when I invoked Source > Format on my changed file,
> it did not apply the formatter rule to move the curly brace back. I
> think there are some bugs in Eclipse's handling of formatter settings
> when the specified profile doesn't exist. Try it on a clean workspace,
> without the Papyrus formatter profile, and see what you observe. Maybe
> I'm doing something wrong...although if so, there's some serious
> usability issues.
>
> Tying this back to Oomph, I don't know if or how it can correctly
> manage formatter settings if these are indeed bugs in the underlying
> JDT functionality.
Forum: EMF
 Topic: [CDO] ArrayStoreException on XML imported resource
[CDO] ArrayStoreException on XML imported resource [message #1518454] Sat, 20 December 2014 04:05
Thorsten Beck is currently offline Thorsten BeckFriend
Messages: 3
Registered: November 2013
Junior Member
Hi,
I'm working with an XSD based ecore model (XSD2Ecore) and managed to build a E4/CDO application around it. The model appears to work fine but when I try to import and load resources from XML I'm running into strange behavior.

The XML is imported to CDO like this
	ResourceSet resourceSet = new ResourceSetImpl();
	resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new MyModelResourceFactoryImpl());
	URI uri = URI.createFileURI(fileName);
	Resource resource = resourceSet.getResource(uri, true);
	if (resource.getContents().get(0) instanceof DocumentRoot) {
		transaction = cdoSession.openTransaction();
		transaction.getOrCreateResource("/home/Administrator/someResource").getContents().add(resource.getContents().get(0));
		transaction.commit();
	}

Then I load the resource and work with its content, e.g. creating a copy:
	view = cdoSession.openView();
	CDOResource resource = view.getResource("/home/Administrator/someResource");
	try {
		resource.load(null);
	} catch (IOException e) {
		e.printStackTrace();
	}
	resource.getResourceSet().getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new MyModelResourceFactoryImpl());
	EcoreUtil.copy(resource.getContents().get(0));

This works fine on the first run, directly after importing the XML. However when I restart my application (including the embedded cdo server) and load the resource using the same code, I get an ArrayStoreException from the call to EcoreUtil.copy(). Ok, some model elements can still be copied, others cannot. That's what confuses me even more.

In the CDO Sessions View I can browse the resource without any problems, so it seems to be intact. Also, there is no problem when I import similar resources from standard XMI.

Any idea what could be causing this issue with the XML imported resources? And why only after restart?

Thanks.

[ERROR] org.eclipse.emf.cdo.internal.common.revision.CDOFeatureMapEntryImpl
java.lang.ArrayStoreException: org.eclipse.emf.cdo.internal.common.revision.CDOFeatureMapEntryImpl
	at org.eclipse.emf.common.util.BasicEList.assign(BasicEList.java:118)
	at org.eclipse.emf.common.util.BasicEList.addUnique(BasicEList.java:442)
	at org.eclipse.emf.common.notify.impl.NotifyingListImpl.doAddUnique(NotifyingListImpl.java:387)
	at org.eclipse.emf.common.notify.impl.NotifyingListImpl.basicAdd(NotifyingListImpl.java:678)
	at org.eclipse.emf.internal.cdo.object.CDOLegacyWrapper.revisionToInstanceFeature(CDOLegacyWrapper.java:622)
	at org.eclipse.emf.internal.cdo.object.CDOLegacyWrapper.revisionToInstance(CDOLegacyWrapper.java:492)
	at org.eclipse.emf.internal.cdo.object.CDOLegacyWrapper.cdoInternalPostLoad(CDOLegacyWrapper.java:367)
	at org.eclipse.emf.internal.cdo.view.AbstractCDOView.cleanObject(AbstractCDOView.java:1254)
	at org.eclipse.emf.internal.cdo.view.AbstractCDOView.createObject(AbstractCDOView.java:1170)
	at org.eclipse.emf.internal.cdo.view.AbstractCDOView.getObject(AbstractCDOView.java:1055)
	at org.eclipse.emf.internal.cdo.view.AbstractCDOView.convertIDToObject(AbstractCDOView.java:1395)
	at org.eclipse.emf.internal.cdo.view.CDOStoreImpl.convertIDToObject(CDOStoreImpl.java:679)
	at org.eclipse.emf.internal.cdo.view.CDOStoreImpl.convertToEMF(CDOStoreImpl.java:647)
	at org.eclipse.emf.internal.cdo.view.CDOStoreImpl.isSet(CDOStoreImpl.java:210)
	at org.eclipse.emf.internal.cdo.CDOObjectImpl.eDynamicIsSet(CDOObjectImpl.java:722)
	at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eIsSet(BasicEObjectImpl.java:1253)
	at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eIsSet(BasicEObjectImpl.java:1237)
	at org.eclipse.emf.ecore.util.EcoreUtil$Copier.copyContainment(EcoreUtil.java:585)
	at org.eclipse.emf.ecore.util.EcoreUtil$Copier.copy(EcoreUtil.java:490)
	at org.eclipse.emf.ecore.util.EcoreUtil$Copier.copyContainment(EcoreUtil.java:599)
	at org.eclipse.emf.ecore.util.EcoreUtil$Copier.copy(EcoreUtil.java:490)
	at org.eclipse.emf.ecore.util.EcoreUtil$Copier.copyAll(EcoreUtil.java:449)
	at org.eclipse.emf.ecore.util.EcoreUtil$Copier.copyContainment(EcoreUtil.java:595)
	at org.eclipse.emf.ecore.util.EcoreUtil$Copier.copy(EcoreUtil.java:490)
	at org.eclipse.emf.ecore.util.EcoreUtil.copy(EcoreUtil.java:357)

[Updated on: Sat, 20 December 2014 04:06]

Report message to a moderator

Re: [CDO] ArrayStoreException on XML imported resource [message #1518578 is a reply to message #1518454] Sat, 20 December 2014 05:44
Eike Stepper is currently offline Eike StepperFriend
Messages: 5590
Registered: July 2009
Senior Member
Hi Thorsten,

You should not call resource.load() on a resource provided by a CDOView. Does that already fix your problem?

Oh, and I see that you're using FeatureMaps. That's not very well supported by CDO. I mean I'm sure that there are many
places in CDO where they're not properly considered.

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Am 20.12.2014 um 05:05 schrieb Thorsten Beck:
> Hi,
> I'm working with an XSD based ecore model (XSD2Ecore) and managed to build a E4/CDO application around it. The model
> appears to work fine but when I try to import and load resources from XML I'm running into strange behavior.
>
> The XML is imported to CDO like this
>
> ResourceSet resourceSet = new ResourceSetImpl();
> resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION,
> new MyModelResourceFactoryImpl());
> URI uri = URI.createFileURI(fileName);
> Resource resource = resourceSet.getResource(uri, true);
> if (resource.getContents().get(0) instanceof DocumentRoot) {
> transaction = cdoSession.openTransaction();
> transaction.getOrCreateResource("/home/Administrator/someResource").getContents().add(resource.getContents().get(0));
> transaction.commit();
> }
>
> Then I load the resource and work with its content, e.g. creating a copy:
>
> view = cdoSession.openView();
> CDOResource resource = view.getResource("/home/Administrator/someResource");
> try {
> resource.load(null);
> } catch (IOException e) {
> e.printStackTrace();
> }
> resource.getResourceSet().getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION,
> new MyModelResourceFactoryImpl());
> EcoreUtil.copy(resource.getContents().get(0));
>
> This works fine on the first run, directly after importing the XML. However when I restart my application (including
> the embedded cdo server) and load the resource using the same code, I get an ArrayStoreException from the call to
> EcoreUtil.copy(). Ok, some model elements can still be copied, others cannot. That's what confuses me even more.
>
> In the CDO Sessions View I can browse the resource without any problems, so it seems to be intact. Also, there is no
> problem when I import similar resources from standard XMI.
>
> Any idea what could be causing this issue with the XML imported resources? And why only after restart?
> Thanks.
>
>
> [ERROR] org.eclipse.emf.cdo.internal.common.revision.CDOFeatureMapEntryImpl
> java.lang.ArrayStoreException: org.eclipse.emf.cdo.internal.common.revision.CDOFeatureMapEntryImpl
> at org.eclipse.emf.common.util.BasicEList.assign(BasicEList.java:118)
> at org.eclipse.emf.common.util.BasicEList.addUnique(BasicEList.java:442)
> at org.eclipse.emf.common.notify.impl.NotifyingListImpl.doAddUnique(NotifyingListImpl.java:387)
> at org.eclipse.emf.common.notify.impl.NotifyingListImpl.basicAdd(NotifyingListImpl.java:678)
> at org.eclipse.emf.internal.cdo.object.CDOLegacyWrapper.revisionToInstanceFeature(CDOLegacyWrapper.java:622)
> at org.eclipse.emf.internal.cdo.object.CDOLegacyWrapper.revisionToInstance(CDOLegacyWrapper.java:492)
> at org.eclipse.emf.internal.cdo.object.CDOLegacyWrapper.cdoInternalPostLoad(CDOLegacyWrapper.java:367)
> at org.eclipse.emf.internal.cdo.view.AbstractCDOView.cleanObject(AbstractCDOView.java:1254)
> at org.eclipse.emf.internal.cdo.view.AbstractCDOView.createObject(AbstractCDOView.java:1170)
> at org.eclipse.emf.internal.cdo.view.AbstractCDOView.getObject(AbstractCDOView.java:1055)
> at org.eclipse.emf.internal.cdo.view.AbstractCDOView.convertIDToObject(AbstractCDOView.java:1395)
> at org.eclipse.emf.internal.cdo.view.CDOStoreImpl.convertIDToObject(CDOStoreImpl.java:679)
> at org.eclipse.emf.internal.cdo.view.CDOStoreImpl.convertToEMF(CDOStoreImpl.java:647)
> at org.eclipse.emf.internal.cdo.view.CDOStoreImpl.isSet(CDOStoreImpl.java:210)
> at org.eclipse.emf.internal.cdo.CDOObjectImpl.eDynamicIsSet(CDOObjectImpl.java:722)
> at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eIsSet(BasicEObjectImpl.java:1253)
> at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eIsSet(BasicEObjectImpl.java:1237)
> at org.eclipse.emf.ecore.util.EcoreUtil$Copier.copyContainment(EcoreUtil.java:585)
> at org.eclipse.emf.ecore.util.EcoreUtil$Copier.copy(EcoreUtil.java:490)
> at org.eclipse.emf.ecore.util.EcoreUtil$Copier.copyContainment(EcoreUtil.java:599)
> at org.eclipse.emf.ecore.util.EcoreUtil$Copier.copy(EcoreUtil.java:490)
> at org.eclipse.emf.ecore.util.EcoreUtil$Copier.copyAll(EcoreUtil.java:449)
> at org.eclipse.emf.ecore.util.EcoreUtil$Copier.copyContainment(EcoreUtil.java:595)
> at org.eclipse.emf.ecore.util.EcoreUtil$Copier.copy(EcoreUtil.java:490)
> at org.eclipse.emf.ecore.util.EcoreUtil.copy(EcoreUtil.java:357)
>
 Topic: Is there a known vulnerability with concurrent calls to ResourceSetImpl.add(Resource)?
Is there a known vulnerability with concurrent calls to ResourceSetImpl.add(Resource)? [message #1518534] Sat, 20 December 2014 05:06
Nicolas Rouquette is currently offline Nicolas RouquetteFriend
Messages: 136
Registered: July 2009
Senior Member
Until recently, we haven't had to register dynamic metamodels in our Eclipse IDE for QVTO development. We could instead register metamodels via their implementations. As far as using the Eclipse IDE to compile source *.qvto files into executable *.qvtox files, the Eclipse QVTO compiler only cares that all metamodels involved have been properly registered. Using the implementations was the simplest way to go. This worked very well for us for several years until now...

Now, we have to deal with fundamentally different versions of metamodels (UML 2.4 and UML 2.5) both of which have dependencies on the same metamodels. The conventional approach would lead to nasty jar conflicts. To be fair, these different versions are not designed to coexist in the same JVM! Since for Eclipse QVTO development we don't technically need to "execute" the metamodel, I thought that I could instead register all of these metamodels as dynamic -- i.e., *.ecore, no java.

In principle it should work (It's been described in several places, including the EMF book). However, I've encountered some problems at Eclipse initialization.

I'm using Eclipse Luna with a lot of EMF-related technology (XCore, QVTO, DiffMerge, EASE, ....) Too much to extract a simple test case but I think the problem is fairly simple.

Basically, there are multiple Eclipse views that, at startup, query the EMF EPackage registry. In the stack traces below, there are 2 views involved:

- the Eclipse QVTO Metamodel Registry view (it shows all the registered metamodels)
- an Eclipse QVTO editor (which makes references to several registered metamodels)

Both initializations trigger NPEs.

Daemon Thread [org.eclipse.m2m.internal.qvt.oml.editor.ui.QvtReconciler] (Suspended (exception NullPointerException))	
	owns: XcoreResource  (id=113)	
	XcoreJavaProjectProvider.getJavaProject(ResourceSet) line: 97	
	XcoreJavaProjectProvider.getClassLoader(ResourceSet) line: 124	
	XcoreEcoreBuilder.getEPackage(XPackage) line: 195	
	XcoreModelAssociator.installDerivedState(DerivedStateAwareResource, boolean) line: 92	
	XcoreResource(DerivedStateAwareResource).installDerivedState(boolean) line: 159	
	XcoreResource(BatchLinkableResource).getContents() line: 133	
	RegistryReader$EPackageDescriptor$Dynamic.getEPackage() line: 251	
	EmfMetamodelDesc.getModel() line: 61	
	EmfMetamodelDesc.getLoadStatus() line: 91	
	MetamodelRegistry.toEPackageRegistry() line: 95	
	CompilerUtils.getEPackageRegistry(URI, IMetamodelRegistryProvider) line: 107	
	QVTOCompiler.getEPackageRegistry(URI) line: 529	
	QVTOCompiler.parse(UnitProxy, QvtCompilerOptions) line: 233	
	QVTOCompiler.doCompile(UnitProxy, QvtCompilerOptions, Monitor) line: 369	
	QVTOCompiler.compileSingleFile(UnitProxy, QvtCompilerOptions, Monitor) line: 326	
	QVTOCompiler.compile(UnitProxy[], QvtCompilerOptions, Monitor) line: 211	
	QVTOCompiler.compile(UnitProxy, QvtCompilerOptions, Monitor) line: 224	
	QvtCompilerFacade.compile(ITextEditor, IDocument, QvtCompilerOptions, IProgressMonitor) line: 77	
	QvtReconcilingStrategy.getCompilationResult(boolean) line: 90	
	QvtReconcilingStrategy.reconcileInternal() line: 74	
	QvtReconcilingStrategy.initialReconcile() line: 62	
	QvtReconciler(MonoReconciler).initialProcess() line: 105	
	AbstractReconciler$BackgroundThread.run() line: 173	


The Eclipse QVTO Metamodel Registry view:

Thread [main] (Suspended (exception NullPointerException))	
	owns: XcoreResource  (id=106)	
	XcoreJavaProjectProvider.getJavaProject(ResourceSet) line: 97	
	XcoreJavaProjectProvider.getClassLoader(ResourceSet) line: 124	
	XcoreEcoreBuilder.getEPackage(XPackage) line: 195	
	XcoreModelAssociator.installDerivedState(DerivedStateAwareResource, boolean) line: 92	
	XcoreResource(DerivedStateAwareResource).installDerivedState(boolean) line: 159	
	XcoreResource(BatchLinkableResource).getContents() line: 133	
	RegistryReader$EPackageDescriptor$Dynamic.getEPackage() line: 251	
	EmfMetamodelDesc.getModel() line: 61	
	MetamodelBrowserView$3(MetamodelBrowser).doCreateInput() line: 502	
	MetamodelBrowser$5.run() line: 473	
	BusyIndicator.showWhile(Display, Runnable) line: 70	
	MetamodelBrowserView$3(MetamodelBrowser).createInput() line: 471	
	MetamodelBrowserView$3(MetamodelBrowser).<init>(Composite, int) line: 168	
	MetamodelBrowserView$3(MetamodelBrowser).<init>(Composite) line: 145	
	MetamodelBrowserView$3.<init>(MetamodelBrowserView, Composite) line: 108	
	MetamodelBrowserView.createPartControl(Composite) line: 108	
	CompatibilityView(CompatibilityPart).createPartControl(IWorkbenchPart, Composite) line: 141	
	CompatibilityView.createPartControl(IWorkbenchPart, Composite) line: 155	
	CompatibilityView(CompatibilityPart).create() line: 327	
	NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]	
	NativeMethodAccessorImpl.invoke(Object, Object[]) line: 62	
	DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43	
	Method.invoke(Object, Object...) line: 483	
	MethodRequestor.execute() line: 55	
	InjectorImpl.processAnnotated(Class<Annotation>, Object, Class<?>, PrimaryObjectSupplier, PrimaryObjectSupplier, ArrayList<Class<?>>) line: 888	
	InjectorImpl.processAnnotated(Class<Annotation>, Object, Class<?>, PrimaryObjectSupplier, PrimaryObjectSupplier, ArrayList<Class<?>>) line: 869	
	InjectorImpl.inject(Object, PrimaryObjectSupplier, PrimaryObjectSupplier) line: 120	
	InjectorImpl.internalMake(Class<?>, PrimaryObjectSupplier, PrimaryObjectSupplier) line: 337	
	InjectorImpl.make(Class<T>, PrimaryObjectSupplier) line: 258	
	ContextInjectionFactory.make(Class<T>, IEclipseContext) line: 162	
	ReflectionContributionFactory.createFromBundle(Bundle, IEclipseContext, IEclipseContext, URI) line: 104	
	ReflectionContributionFactory.doCreate(String, IEclipseContext, IEclipseContext) line: 73	
	ReflectionContributionFactory.create(String, IEclipseContext) line: 55	
	ContributedPartRenderer.createWidget(MUIElement, Object) line: 127	
	PartRenderingEngine.createWidget(MUIElement, Object) line: 983	
	PartRenderingEngine.safeCreateGui(MUIElement, Object, IEclipseContext) line: 662	
	PartRenderingEngine$6.run() line: 547	
	SafeRunner.run(ISafeRunnable) line: 42	
	PartRenderingEngine.createGui(MUIElement, Object, IEclipseContext) line: 531	
	ElementReferenceRenderer.createWidget(MUIElement, Object) line: 69	
	PartRenderingEngine.createWidget(MUIElement, Object) line: 983	
	PartRenderingEngine.safeCreateGui(MUIElement, Object, IEclipseContext) line: 662	
	PartRenderingEngine.safeCreateGui(MUIElement) line: 766	
	PartRenderingEngine.access$2(PartRenderingEngine, MUIElement) line: 737	
	PartRenderingEngine$7.run() line: 731	
	SafeRunner.run(ISafeRunnable) line: 42	
	PartRenderingEngine.createGui(MUIElement) line: 715	
	StackRenderer.showTab(MUIElement) line: 1250	
	StackRenderer(LazyStackRenderer).postProcess(MUIElement) line: 100	
	PartRenderingEngine.safeCreateGui(MUIElement, Object, IEclipseContext) line: 678	
	PartRenderingEngine.safeCreateGui(MUIElement) line: 766	
	PartRenderingEngine.access$2(PartRenderingEngine, MUIElement) line: 737	
	PartRenderingEngine$7.run() line: 731	
	SafeRunner.run(ISafeRunnable) line: 42	
	PartRenderingEngine.createGui(MUIElement) line: 715	
	SashRenderer(SWTPartRenderer).processContents(MElementContainer<MUIElement>) line: 68	
	SashRenderer.processContents(MElementContainer<MUIElement>) line: 185	
	PartRenderingEngine.safeCreateGui(MUIElement, Object, IEclipseContext) line: 674	
	PartRenderingEngine.safeCreateGui(MUIElement) line: 766	
	PartRenderingEngine.access$2(PartRenderingEngine, MUIElement) line: 737	
	PartRenderingEngine$7.run() line: 731	
	SafeRunner.run(ISafeRunnable) line: 42	
	PartRenderingEngine.createGui(MUIElement) line: 715	
	SashRenderer(SWTPartRenderer).processContents(MElementContainer<MUIElement>) line: 68	
	SashRenderer.processContents(MElementContainer<MUIElement>) line: 185	
	PartRenderingEngine.safeCreateGui(MUIElement, Object, IEclipseContext) line: 674	
	PartRenderingEngine.safeCreateGui(MUIElement) line: 766	
	PartRenderingEngine.access$2(PartRenderingEngine, MUIElement) line: 737	
	PartRenderingEngine$7.run() line: 731	
	SafeRunner.run(ISafeRunnable) line: 42	
	PartRenderingEngine.createGui(MUIElement) line: 715	
	SashRenderer(SWTPartRenderer).processContents(MElementContainer<MUIElement>) line: 68	
	SashRenderer.processContents(MElementContainer<MUIElement>) line: 185	
	PartRenderingEngine.safeCreateGui(MUIElement, Object, IEclipseContext) line: 674	
	PartRenderingEngine.safeCreateGui(MUIElement) line: 766	
	PartRenderingEngine.access$2(PartRenderingEngine, MUIElement) line: 737	
	PartRenderingEngine$7.run() line: 731	
	SafeRunner.run(ISafeRunnable) line: 42	
	PartRenderingEngine.createGui(MUIElement) line: 715	
	PerspectiveRenderer(SWTPartRenderer).processContents(MElementContainer<MUIElement>) line: 68	
	PerspectiveRenderer.processContents(MElementContainer<MUIElement>) line: 49	
	PartRenderingEngine.safeCreateGui(MUIElement, Object, IEclipseContext) line: 674	
	PartRenderingEngine.safeCreateGui(MUIElement) line: 766	
	PartRenderingEngine.access$2(PartRenderingEngine, MUIElement) line: 737	
	PartRenderingEngine$7.run() line: 731	
	SafeRunner.run(ISafeRunnable) line: 42	
	PartRenderingEngine.createGui(MUIElement) line: 715	
	PerspectiveStackRenderer.showTab(MUIElement) line: 103	
	PerspectiveStackRenderer(LazyStackRenderer).postProcess(MUIElement) line: 100	
	PerspectiveStackRenderer.postProcess(MUIElement) line: 77	
	PartRenderingEngine.safeCreateGui(MUIElement, Object, IEclipseContext) line: 678	
	PartRenderingEngine.safeCreateGui(MUIElement) line: 766	
	PartRenderingEngine.access$2(PartRenderingEngine, MUIElement) line: 737	
	PartRenderingEngine$7.run() line: 731	
	SafeRunner.run(ISafeRunnable) line: 42	
	PartRenderingEngine.createGui(MUIElement) line: 715	
	SashRenderer(SWTPartRenderer).processContents(MElementContainer<MUIElement>) line: 68	
	SashRenderer.processContents(MElementContainer<MUIElement>) line: 185	
	PartRenderingEngine.safeCreateGui(MUIElement, Object, IEclipseContext) line: 674	
	PartRenderingEngine.safeCreateGui(MUIElement) line: 766	
	PartRenderingEngine.access$2(PartRenderingEngine, MUIElement) line: 737	
	PartRenderingEngine$7.run() line: 731	
	SafeRunner.run(ISafeRunnable) line: 42	
	PartRenderingEngine.createGui(MUIElement) line: 715	
	WBWRenderer(SWTPartRenderer).processContents(MElementContainer<MUIElement>) line: 68	
	WBWRenderer.processContents(MElementContainer<MUIElement>) line: 664	
	PartRenderingEngine.safeCreateGui(MUIElement, Object, IEclipseContext) line: 674	
	PartRenderingEngine.safeCreateGui(MUIElement) line: 766	
	PartRenderingEngine.access$2(PartRenderingEngine, MUIElement) line: 737	
	PartRenderingEngine$7.run() line: 731	
	SafeRunner.run(ISafeRunnable) line: 42	
	PartRenderingEngine.createGui(MUIElement) line: 715	
	PartRenderingEngine$9.run() line: 1078	
	Realm.runWithDefault(Realm, Runnable) line: 332	
	PartRenderingEngine.run(MApplicationElement, IEclipseContext) line: 1032	
	E4Workbench.createAndRunUI(MApplicationElement) line: 148	
	Workbench$5.run() line: 636	
	Realm.runWithDefault(Realm, Runnable) line: 332	
	Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 579	
	PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 150	
	IDEApplication.start(IApplicationContext) line: 135	
	EclipseAppHandle.run(Object) line: 196	
	EclipseAppLauncher.runApplication(Object) line: 134	
	EclipseAppLauncher.start(Object) line: 104	
	EclipseStarter.run(Object) line: 380	
	EclipseStarter.run(String[], Runnable) line: 235	
	NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]	
	NativeMethodAccessorImpl.invoke(Object, Object[]) line: 62	
	DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43	
	Method.invoke(Object, Object...) line: 483	
	Main.invokeFramework(String[], URL[]) line: 648	
	Main.basicRun(String[]) line: 603	
	Main.run(String[]) line: 1465	
	Main.main(String[]) line: 1438	


These 2 threads are trying to register the same EPackage: xcore.lang

The NPE is caused by the fact that the ResourceSet's resources contains a NULL!

      for (Resource resource : resourceSet.getResources())
      {
        URI uri = resource.getURI(); // NPE because resource is null!
        ...
      }


There was a misleading NPE that turns out to be a minor vulnerability in the EMF RegistryReader:

diff --git a/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/plugin/RegistryReader.java b/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/plugin/RegistryReader.java
index 9666a50..bf098c3 100644
--- a/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/plugin/RegistryReader.java
+++ b/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/plugin/RegistryReader.java
@@ -24,9 +24,11 @@ import org.eclipse.core.runtime.IExtensionRegistry;
 import org.eclipse.core.runtime.IRegistryChangeEvent;
 import org.eclipse.core.runtime.IRegistryChangeListener;
 import org.eclipse.emf.common.CommonPlugin;
+import org.eclipse.emf.common.util.EList;
 import org.eclipse.emf.common.util.URI;
 import org.eclipse.emf.common.util.WrappedException;
 import org.eclipse.emf.ecore.EFactory;
+import org.eclipse.emf.ecore.EObject;
 import org.eclipse.emf.ecore.EPackage;
 import org.eclipse.emf.ecore.EcorePackage;
 import org.eclipse.emf.ecore.resource.Resource;
@@ -244,7 +246,11 @@ public abstract class RegistryReader
             }
             else
             {
-              return (EPackage) EcoreUtil.getObjectByType(resourceSet.getResource(locationURI, true).getContents(), EcorePackage.Literals.EPACKAGE);
+              Resource r = resourceSet.getResource(locationURI, true);
+              if (r != null)
+                       return (EPackage) EcoreUtil.getObjectByType(r.getContents(), EcorePackage.Literals.EPACKAGE);
+              else
+                   throw new RuntimeException("No EPackage found at: " + locationURI);
             }
           }
           else


Basically, the original code assumes that resourceSet.getResource(...) never returns null. AFAIK, there is no such guarantee at the point in the logic.

With this NPE vulnerability aside, we are left with the problem: how could a ResourceSet have a null resource?

This should not happen but it obviously does in this case.

The problem is really due to concurrent calls to ResourceSet.add(Resource) because
the default implementation (i.e. ResourceSetImpl) is not thread-safe for concurrent modification.

I managed to work around the problem by synchronizing calls to ResourceSetImpl::add(Resource):

diff --git a/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/resource/impl/ResourceSetImpl.java b/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/resource/impl/ResourceSetImpl.java
index 6f896e8..9792542 100644
--- a/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/resource/impl/ResourceSetImpl.java
+++ b/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/resource/impl/ResourceSetImpl.java
@@ -432,7 +432,9 @@ public class ResourceSetImpl extends NotifierImpl implements ResourceSet
     if (resourceFactory != null)
     {
       Resource result = resourceFactory.createResource(uri);
-      getResources().add(result);
+      if (result != null) {
+               getResources().add(result);
+      }
       return result;
     }
     else
@@ -609,6 +611,14 @@ public class ResourceSetImpl extends NotifierImpl implements ResourceSet
     {
       return size <= 4 ? super.contains(object) : object instanceof Resource && ((Resource)object).getResourceSet() == ResourceSetImpl.this;
     }
+
+       @Override
+       public boolean add(E object) {
+               synchronized(this) {
+                       return super.add(object);
+               }
+       }
+    
   }


The evidence that this workaround is effective is that if I comment out the synchronized guard in the call to super.add(object), then I get NPEs on 2 threads at initialization.

Has anyone encountered this problem before?

Is there a test case that involves plugins that register dynamic metamodels?

If yes, I'd like to see if I can reproduce this problem in a simpler environment by opening the Eclipse QVTO metamodel registry view and an Eclipse QVTO editor.
This seems to be enough to concurrent threads that will initialize the EMF EPackage registry and therefore force adding metamodel resources to the same ResourceSet.

On the other hand, it is rather interesting that these NPEs have systematically happened during the initialization of XCore even though the examples I made do not involve XCore's metamodels (except for the Eclipse QVTO Metamodel Registry view which shows all registered metamodels -- static & dynamic)

- Nicolas.
Re: Is there a known vulnerability with concurrent calls to ResourceSetImpl.add(Resource)? [message #1518882 is a reply to message #1518534] Sat, 20 December 2014 09:52
Ed Merks is currently offline Ed MerksFriend
Messages: 26285
Registered: July 2009
Senior Member
Nicolas,

Comments below.

On 20/12/2014 6:06 AM, Nicolas Rouquette wrote:
> Until recently, we haven't had to register dynamic metamodels in our
> Eclipse IDE for QVTO development. We could instead register metamodels
> via their implementations. As far as using the Eclipse IDE to compile
> source *.qvto files into executable *.qvtox files, the Eclipse QVTO
> compiler only cares that all metamodels involved have been properly
> registered. Using the implementations was the simplest way to go. This
> worked very well for us for several years until now...
>
> Now, we have to deal with fundamentally different versions of
> metamodels (UML 2.4 and UML 2.5) both of which have dependencies on
> the same metamodels. The conventional approach would lead to nasty jar
> conflicts. To be fair, these different versions are not designed to
> coexist in the same JVM! Since for Eclipse QVTO development we don't
> technically need to "execute" the metamodel, I thought that I could
> instead register all of these metamodels as dynamic -- i.e., *.ecore,
> no java.
>
> In principle it should work (It's been described in several places,
> including the EMF book). However, I've encountered some problems at
> Eclipse initialization.
>
> I'm using Eclipse Luna with a lot of EMF-related technology (XCore,
> QVTO, DiffMerge, EASE, ....) Too much to extract a simple test case
> but I think the problem is fairly simple.
>
> Basically, there are multiple Eclipse views that, at startup, query
> the EMF EPackage registry. In the stack traces below, there are 2
> views involved:
>
> - the Eclipse QVTO Metamodel Registry view (it shows all the
> registered metamodels)
> - an Eclipse QVTO editor (which makes references to several registered
> metamodels)
>
> Both initializations trigger NPEs.
>
>
> Daemon Thread
> [org.eclipse.m2m.internal.qvt.oml.editor.ui.QvtReconciler] (Suspended
> (exception NullPointerException))
> owns: XcoreResource (id=113)
> XcoreJavaProjectProvider.getJavaProject(ResourceSet) line: 97
> XcoreJavaProjectProvider.getClassLoader(ResourceSet) line: 124
> XcoreEcoreBuilder.getEPackage(XPackage) line: 195
> XcoreModelAssociator.installDerivedState(DerivedStateAwareResource, boolean)
> line: 92
> XcoreResource(DerivedStateAwareResource).installDerivedState(boolean)
> line: 159
> XcoreResource(BatchLinkableResource).getContents() line: 133
> RegistryReader$EPackageDescriptor$Dynamic.getEPackage() line: 251
> EmfMetamodelDesc.getModel() line: 61
> EmfMetamodelDesc.getLoadStatus() line: 91
> MetamodelRegistry.toEPackageRegistry() line: 95
> CompilerUtils.getEPackageRegistry(URI, IMetamodelRegistryProvider)
> line: 107
> QVTOCompiler.getEPackageRegistry(URI) line: 529
> QVTOCompiler.parse(UnitProxy, QvtCompilerOptions) line: 233
> QVTOCompiler.doCompile(UnitProxy, QvtCompilerOptions, Monitor)
> line: 369
> QVTOCompiler.compileSingleFile(UnitProxy, QvtCompilerOptions,
> Monitor) line: 326
> QVTOCompiler.compile(UnitProxy[], QvtCompilerOptions, Monitor)
> line: 211
> QVTOCompiler.compile(UnitProxy, QvtCompilerOptions, Monitor) line:
> 224
> QvtCompilerFacade.compile(ITextEditor, IDocument,
> QvtCompilerOptions, IProgressMonitor) line: 77
> QvtReconcilingStrategy.getCompilationResult(boolean) line: 90
> QvtReconcilingStrategy.reconcileInternal() line: 74
> QvtReconcilingStrategy.initialReconcile() line: 62
> QvtReconciler(MonoReconciler).initialProcess() line: 105
> AbstractReconciler$BackgroundThread.run() line: 173
>
>
> The Eclipse QVTO Metamodel Registry view:
>
>
> Thread [main] (Suspended (exception NullPointerException))
> owns: XcoreResource (id=106)
> XcoreJavaProjectProvider.getJavaProject(ResourceSet) line: 97
> XcoreJavaProjectProvider.getClassLoader(ResourceSet) line: 124
> XcoreEcoreBuilder.getEPackage(XPackage) line: 195
> XcoreModelAssociator.installDerivedState(DerivedStateAwareResource, boolean)
> line: 92
> XcoreResource(DerivedStateAwareResource).installDerivedState(boolean)
> line: 159
> XcoreResource(BatchLinkableResource).getContents() line: 133
> RegistryReader$EPackageDescriptor$Dynamic.getEPackage() line: 251
> EmfMetamodelDesc.getModel() line: 61
> MetamodelBrowserView$3(MetamodelBrowser).doCreateInput() line: 502
> MetamodelBrowser$5.run() line: 473
> BusyIndicator.showWhile(Display, Runnable) line: 70
> MetamodelBrowserView$3(MetamodelBrowser).createInput() line: 471
> MetamodelBrowserView$3(MetamodelBrowser).<init>(Composite, int)
> line: 168
> MetamodelBrowserView$3(MetamodelBrowser).<init>(Composite) line: 145
> MetamodelBrowserView$3.<init>(MetamodelBrowserView, Composite)
> line: 108
> MetamodelBrowserView.createPartControl(Composite) line: 108
> CompatibilityView(CompatibilityPart).createPartControl(IWorkbenchPart,
> Composite) line: 141
> CompatibilityView.createPartControl(IWorkbenchPart, Composite)
> line: 155
> CompatibilityView(CompatibilityPart).create() line: 327
> NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line:
> not available [native method]
> NativeMethodAccessorImpl.invoke(Object, Object[]) line: 62
> DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43
> Method.invoke(Object, Object...) line: 483
> MethodRequestor.execute() line: 55
> InjectorImpl.processAnnotated(Class<Annotation>, Object, Class<?>,
> PrimaryObjectSupplier, PrimaryObjectSupplier, ArrayList<Class<?>>)
> line: 888
> InjectorImpl.processAnnotated(Class<Annotation>, Object, Class<?>,
> PrimaryObjectSupplier, PrimaryObjectSupplier, ArrayList<Class<?>>)
> line: 869
> InjectorImpl.inject(Object, PrimaryObjectSupplier,
> PrimaryObjectSupplier) line: 120
> InjectorImpl.internalMake(Class<?>, PrimaryObjectSupplier,
> PrimaryObjectSupplier) line: 337
> InjectorImpl.make(Class<T>, PrimaryObjectSupplier) line: 258
> ContextInjectionFactory.make(Class<T>, IEclipseContext) line: 162
> ReflectionContributionFactory.createFromBundle(Bundle,
> IEclipseContext, IEclipseContext, URI) line: 104
> ReflectionContributionFactory.doCreate(String, IEclipseContext,
> IEclipseContext) line: 73
> ReflectionContributionFactory.create(String, IEclipseContext)
> line: 55
> ContributedPartRenderer.createWidget(MUIElement, Object) line: 127
> PartRenderingEngine.createWidget(MUIElement, Object) line: 983
> PartRenderingEngine.safeCreateGui(MUIElement, Object,
> IEclipseContext) line: 662
> PartRenderingEngine$6.run() line: 547
> SafeRunner.run(ISafeRunnable) line: 42
> PartRenderingEngine.createGui(MUIElement, Object, IEclipseContext)
> line: 531
> ElementReferenceRenderer.createWidget(MUIElement, Object) line: 69
> PartRenderingEngine.createWidget(MUIElement, Object) line: 983
> PartRenderingEngine.safeCreateGui(MUIElement, Object,
> IEclipseContext) line: 662
> PartRenderingEngine.safeCreateGui(MUIElement) line: 766
> PartRenderingEngine.access$2(PartRenderingEngine, MUIElement)
> line: 737
> PartRenderingEngine$7.run() line: 731
> SafeRunner.run(ISafeRunnable) line: 42
> PartRenderingEngine.createGui(MUIElement) line: 715
> StackRenderer.showTab(MUIElement) line: 1250
> StackRenderer(LazyStackRenderer).postProcess(MUIElement) line: 100
> PartRenderingEngine.safeCreateGui(MUIElement, Object,
> IEclipseContext) line: 678
> PartRenderingEngine.safeCreateGui(MUIElement) line: 766
> PartRenderingEngine.access$2(PartRenderingEngine, MUIElement)
> line: 737
> PartRenderingEngine$7.run() line: 731
> SafeRunner.run(ISafeRunnable) line: 42
> PartRenderingEngine.createGui(MUIElement) line: 715
> SashRenderer(SWTPartRenderer).processContents(MElementContainer<MUIElement>)
> line: 68
> SashRenderer.processContents(MElementContainer<MUIElement>) line: 185
> PartRenderingEngine.safeCreateGui(MUIElement, Object,
> IEclipseContext) line: 674
> PartRenderingEngine.safeCreateGui(MUIElement) line: 766
> PartRenderingEngine.access$2(PartRenderingEngine, MUIElement)
> line: 737
> PartRenderingEngine$7.run() line: 731
> SafeRunner.run(ISafeRunnable) line: 42
> PartRenderingEngine.createGui(MUIElement) line: 715
> SashRenderer(SWTPartRenderer).processContents(MElementContainer<MUIElement>)
> line: 68
> SashRenderer.processContents(MElementContainer<MUIElement>) line: 185
> PartRenderingEngine.safeCreateGui(MUIElement, Object,
> IEclipseContext) line: 674
> PartRenderingEngine.safeCreateGui(MUIElement) line: 766
> PartRenderingEngine.access$2(PartRenderingEngine, MUIElement)
> line: 737
> PartRenderingEngine$7.run() line: 731
> SafeRunner.run(ISafeRunnable) line: 42
> PartRenderingEngine.createGui(MUIElement) line: 715
> SashRenderer(SWTPartRenderer).processContents(MElementContainer<MUIElement>)
> line: 68
> SashRenderer.processContents(MElementContainer<MUIElement>) line: 185
> PartRenderingEngine.safeCreateGui(MUIElement, Object,
> IEclipseContext) line: 674
> PartRenderingEngine.safeCreateGui(MUIElement) line: 766
> PartRenderingEngine.access$2(PartRenderingEngine, MUIElement)
> line: 737
> PartRenderingEngine$7.run() line: 731
> SafeRunner.run(ISafeRunnable) line: 42
> PartRenderingEngine.createGui(MUIElement) line: 715
> PerspectiveRenderer(SWTPartRenderer).processContents(MElementContainer<MUIElement>)
> line: 68
> PerspectiveRenderer.processContents(MElementContainer<MUIElement>)
> line: 49
> PartRenderingEngine.safeCreateGui(MUIElement, Object,
> IEclipseContext) line: 674
> PartRenderingEngine.safeCreateGui(MUIElement) line: 766
> PartRenderingEngine.access$2(PartRenderingEngine, MUIElement)
> line: 737
> PartRenderingEngine$7.run() line: 731
> SafeRunner.run(ISafeRunnable) line: 42
> PartRenderingEngine.createGui(MUIElement) line: 715
> PerspectiveStackRenderer.showTab(MUIElement) line: 103
> PerspectiveStackRenderer(LazyStackRenderer).postProcess(MUIElement) line:
> 100
> PerspectiveStackRenderer.postProcess(MUIElement) line: 77
> PartRenderingEngine.safeCreateGui(MUIElement, Object,
> IEclipseContext) line: 678
> PartRenderingEngine.safeCreateGui(MUIElement) line: 766
> PartRenderingEngine.access$2(PartRenderingEngine, MUIElement)
> line: 737
> PartRenderingEngine$7.run() line: 731
> SafeRunner.run(ISafeRunnable) line: 42
> PartRenderingEngine.createGui(MUIElement) line: 715
> SashRenderer(SWTPartRenderer).processContents(MElementContainer<MUIElement>)
> line: 68
> SashRenderer.processContents(MElementContainer<MUIElement>) line: 185
> PartRenderingEngine.safeCreateGui(MUIElement, Object,
> IEclipseContext) line: 674
> PartRenderingEngine.safeCreateGui(MUIElement) line: 766
> PartRenderingEngine.access$2(PartRenderingEngine, MUIElement)
> line: 737
> PartRenderingEngine$7.run() line: 731
> SafeRunner.run(ISafeRunnable) line: 42
> PartRenderingEngine.createGui(MUIElement) line: 715
> WBWRenderer(SWTPartRenderer).processContents(MElementContainer<MUIElement>)
> line: 68
> WBWRenderer.processContents(MElementContainer<MUIElement>) line: 664
> PartRenderingEngine.safeCreateGui(MUIElement, Object,
> IEclipseContext) line: 674
> PartRenderingEngine.safeCreateGui(MUIElement) line: 766
> PartRenderingEngine.access$2(PartRenderingEngine, MUIElement)
> line: 737
> PartRenderingEngine$7.run() line: 731
> SafeRunner.run(ISafeRunnable) line: 42
> PartRenderingEngine.createGui(MUIElement) line: 715
> PartRenderingEngine$9.run() line: 1078
> Realm.runWithDefault(Realm, Runnable) line: 332
> PartRenderingEngine.run(MApplicationElement, IEclipseContext)
> line: 1032
> E4Workbench.createAndRunUI(MApplicationElement) line: 148
> Workbench$5.run() line: 636
> Realm.runWithDefault(Realm, Runnable) line: 332
> Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 579
> PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 150
> IDEApplication.start(IApplicationContext) line: 135
> EclipseAppHandle.run(Object) line: 196
> EclipseAppLauncher.runApplication(Object) line: 134
> EclipseAppLauncher.start(Object) line: 104
> EclipseStarter.run(Object) line: 380
> EclipseStarter.run(String[], Runnable) line: 235
> NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line:
> not available [native method]
> NativeMethodAccessorImpl.invoke(Object, Object[]) line: 62
> DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43
> Method.invoke(Object, Object...) line: 483
> Main.invokeFramework(String[], URL[]) line: 648
> Main.basicRun(String[]) line: 603
> Main.run(String[]) line: 1465
> Main.main(String[]) line: 1438
>
>
> These 2 threads are trying to register the same EPackage: xcore.lang
>
> The NPE is caused by the fact that the ResourceSet's resources
> contains a NULL!
>
>
> for (Resource resource : resourceSet.getResources())
> {
> URI uri = resource.getURI(); // NPE because resource is null!
> ...
> }
>
>
> There was a misleading NPE that turns out to be a minor vulnerability
> in the EMF RegistryReader:
>
>
> diff --git
> a/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/plugin/RegistryReader.java
> b/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/plugin/RegistryReader.java
>
> index 9666a50..bf098c3 100644
> ---
> a/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/plugin/RegistryReader.java
> +++
> b/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/plugin/RegistryReader.java
> @@ -24,9 +24,11 @@ import org.eclipse.core.runtime.IExtensionRegistry;
> import org.eclipse.core.runtime.IRegistryChangeEvent;
> import org.eclipse.core.runtime.IRegistryChangeListener;
> import org.eclipse.emf.common.CommonPlugin;
> +import org.eclipse.emf.common.util.EList;
> import org.eclipse.emf.common.util.URI;
> import org.eclipse.emf.common.util.WrappedException;
> import org.eclipse.emf.ecore.EFactory;
> +import org.eclipse.emf.ecore.EObject;
> import org.eclipse.emf.ecore.EPackage;
> import org.eclipse.emf.ecore.EcorePackage;
> import org.eclipse.emf.ecore.resource.Resource;
> @@ -244,7 +246,11 @@ public abstract class RegistryReader
> }
> else
> {
> - return (EPackage)
> EcoreUtil.getObjectByType(resourceSet.getResource(locationURI,
> true).getContents(), EcorePackage.Literals.EPACKAGE);
> + Resource r = resourceSet.getResource(locationURI, true);
> + if (r != null)
> + return (EPackage)
> EcoreUtil.getObjectByType(r.getContents(),
> EcorePackage.Literals.EPACKAGE);
> + else
> + throw new RuntimeException("No EPackage found at:
> " + locationURI);
> }
> }
> else
>
>
> Basically, the original code assumes that resourceSet.getResource(...)
> never returns null. AFAIK, there is no such guarantee at the point in
> the logic.
This sounds more likely to be a problem with no resource factory being
registered for *.xcore. https://bugs.eclipse.org/bugs/show_bug.cgi?id=453329
>
> With this NPE vulnerability aside, we are left with the problem: how
> could a ResourceSet have a null resource?
>
> This should not happen but it obviously does in this case.
>
> The problem is really due to concurrent calls to
> ResourceSet.add(Resource) because the default implementation (i.e.
> ResourceSetImpl) is not thread-safe for concurrent modification.
> I managed to work around the problem by synchronizing calls to
> ResourceSetImpl::add(Resource):
No, resource sets aren't designed or intended to be thread safe and
adding synchronization will be a source of deadlock. Better to look at
something like
org.eclipse.emf.ecore.plugin.RegistryReader.EPackageDescriptor.Dynamic.getEPackage()
and make sure that it hold a lock on the resource set rather than start
sprinkling synchronization into all resource set implementations.
>
>
> diff --git
> a/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/resource/impl/ResourceSetImpl.java
> b/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/resource/impl/ResourceSetImpl.java
>
> index 6f896e8..9792542 100644
> ---
> a/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/resource/impl/ResourceSetImpl.java
> +++
> b/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/resource/impl/ResourceSetImpl.java
> @@ -432,7 +432,9 @@ public class ResourceSetImpl extends NotifierImpl
> implements ResourceSet
> if (resourceFactory != null)
> {
> Resource result = resourceFactory.createResource(uri);
> - getResources().add(result);
> + if (result != null) {
> + getResources().add(result);
> + }
> return result;
> }
> else
> @@ -609,6 +611,14 @@ public class ResourceSetImpl extends NotifierImpl
> implements ResourceSet
> {
> return size <= 4 ? super.contains(object) : object instanceof
> Resource && ((Resource)object).getResourceSet() == ResourceSetImpl.this;
> }
> +
> + @Override
> + public boolean add(E object) {
> + synchronized(this) {
> + return super.add(object);
> + }
> + }
> + }
>
>
> The evidence that this workaround is effective is that if I comment
> out the synchronized guard in the call to super.add(object), then I
> get NPEs on 2 threads at initialization.
> Has anyone encountered this problem before?
No.
>
> Is there a test case that involves plugins that register dynamic
> metamodels?
No.
>
> If yes, I'd like to see if I can reproduce this problem in a simpler
> environment by opening the Eclipse QVTO metamodel registry view and an
> Eclipse QVTO editor.
> This seems to be enough to concurrent threads that will initialize the
> EMF EPackage registry and therefore force adding metamodel resources
> to the same ResourceSet.
We'd need a new test case, but it's pretty clear from inspection that
org.eclipse.emf.ecore.plugin.RegistryReader.EPackageDescriptor.Dynamic.getEPackage()
isn't thread safe.
>
> On the other hand, it is rather interesting that these NPEs have
> systematically happened during the initialization of XCore even though
> the examples I made do not involve XCore's metamodels (except for the
> Eclipse QVTO Metamodel Registry view which shows all registered
> metamodels -- static & dynamic)
Yes, that's a little odd. I do get the sense that something
(MetamodelRegistry.toEPackageRegistry()?) is aggressively loading all
registered models.
>
> - Nicolas.
Re: Is there a known vulnerability with concurrent calls to ResourceSetImpl.add(Resource)? [message #1518908 is a reply to message #1518534] Sat, 20 December 2014 10:10
Ed Willink is currently offline Ed WillinkFriend
Messages: 4188
Registered: July 2009
Senior Member
Hi Nicolas

EMF has a very sensible thread safety policy: [1]

"EMF can safely be used in multi-threaded environments; however, EMF
does not, itself, ensure thread-safety in application model
implementations. Data structures are unsynchronized, for performance and
to avoid potential deadlock situations. The expectation is that a
complete instance of the model (including resources and resource set, if
present) should only be accessed by one thread at a time, and that the
synchronization should be provided by the application at a higher level. "

This worked well for many years. Recently EMF UI tooling has been
improving with facilities such as live validation without full
consideration of the consequent elevation of EMF single-threaded tools
to the status of applications.

This is particularly serious for UML where profiles are loaded lazily.
Consequently what an EMF developer might consider to be a simple short
sharp activity is not simple at all since what appeared to be a trivial
eGet() might actually involve loading 10 UML models and a ResourceSet
modification. I have raised at least a couple of CME bugs that this
laziness has exposed.

This can be differently serious when OCL enrichment is used, since once
again a simple eGet() may involve OCL parsing, model loading and
evaluation of the relevant OCL delegate body.

There are a couple of recent bug fixes that mitigate these hazards.

Your problem seems slightly adjacent. At the simplest level, if you are
not using Xcore then why are Xcore resources being loaded? I vaguely
recall raising a QVTo bug to the effect that a registry scan was being
over-enthusiastic; it can easily cause all installed model plugins o be
activated.

I recommend investigating why QVTo is allowing Xcore to incur
non-trivial costs and identifying what the concurrent activities are and
why they are not synchronized. A few years ago a validation hazard was
resolved by synchronizing on the ResourceSet, but I am not aware of any
documentation to establish a more general inter-thread design approach.

Regards

Ed Willink




[1] https://wiki.eclipse.org/EMF/FAQ#Is_EMF_thread-safe.3F



On 20/12/2014 05:06, Nicolas Rouquette wrote:
> Until recently, we haven't had to register dynamic metamodels in our
> Eclipse IDE for QVTO development. We could instead register metamodels
> via their implementations. As far as using the Eclipse IDE to compile
> source *.qvto files into executable *.qvtox files, the Eclipse QVTO
> compiler only cares that all metamodels involved have been properly
> registered. Using the implementations was the simplest way to go. This
> worked very well for us for several years until now...
>
> Now, we have to deal with fundamentally different versions of metamodels
> (UML 2.4 and UML 2.5) both of which have dependencies on the same
> metamodels. The conventional approach would lead to nasty jar conflicts.
> To be fair, these different versions are not designed to coexist in the
> same JVM! Since for Eclipse QVTO development we don't technically need
> to "execute" the metamodel, I thought that I could instead register all
> of these metamodels as dynamic -- i.e., *.ecore, no java.
>
> In principle it should work (It's been described in several places,
> including the EMF book). However, I've encountered some problems at
> Eclipse initialization.
>
> I'm using Eclipse Luna with a lot of EMF-related technology (XCore,
> QVTO, DiffMerge, EASE, ....) Too much to extract a simple test case but
> I think the problem is fairly simple.
>
> Basically, there are multiple Eclipse views that, at startup, query the
> EMF EPackage registry. In the stack traces below, there are 2 views
> involved:
>
> - the Eclipse QVTO Metamodel Registry view (it shows all the registered
> metamodels)
> - an Eclipse QVTO editor (which makes references to several registered
> metamodels)
>
> Both initializations trigger NPEs.
>
>
> Daemon Thread [org.eclipse.m2m.internal.qvt.oml.editor.ui.QvtReconciler]
> (Suspended (exception NullPointerException))
> owns: XcoreResource (id=113)
> XcoreJavaProjectProvider.getJavaProject(ResourceSet) line: 97
> XcoreJavaProjectProvider.getClassLoader(ResourceSet) line: 124
> XcoreEcoreBuilder.getEPackage(XPackage) line: 195
> XcoreModelAssociator.installDerivedState(DerivedStateAwareResource,
> boolean) line: 92
> XcoreResource(DerivedStateAwareResource).installDerivedState(boolean) line: 159
> XcoreResource(BatchLinkableResource).getContents() line: 133
> RegistryReader$EPackageDescriptor$Dynamic.getEPackage() line: 251
> EmfMetamodelDesc.getModel() line: 61
> EmfMetamodelDesc.getLoadStatus() line: 91
> MetamodelRegistry.toEPackageRegistry() line: 95
> CompilerUtils.getEPackageRegistry(URI, IMetamodelRegistryProvider)
> line: 107
> QVTOCompiler.getEPackageRegistry(URI) line: 529
> QVTOCompiler.parse(UnitProxy, QvtCompilerOptions) line: 233
> QVTOCompiler.doCompile(UnitProxy, QvtCompilerOptions, Monitor)
> line: 369
> QVTOCompiler.compileSingleFile(UnitProxy, QvtCompilerOptions,
> Monitor) line: 326
> QVTOCompiler.compile(UnitProxy[], QvtCompilerOptions, Monitor)
> line: 211
> QVTOCompiler.compile(UnitProxy, QvtCompilerOptions, Monitor) line: 224
> QvtCompilerFacade.compile(ITextEditor, IDocument,
> QvtCompilerOptions, IProgressMonitor) line: 77
> QvtReconcilingStrategy.getCompilationResult(boolean) line: 90
> QvtReconcilingStrategy.reconcileInternal() line: 74
> QvtReconcilingStrategy.initialReconcile() line: 62
> QvtReconciler(MonoReconciler).initialProcess() line: 105
> AbstractReconciler$BackgroundThread.run() line: 173
>
>
> The Eclipse QVTO Metamodel Registry view:
>
>
> Thread [main] (Suspended (exception NullPointerException))
> owns: XcoreResource (id=106)
> XcoreJavaProjectProvider.getJavaProject(ResourceSet) line: 97
> XcoreJavaProjectProvider.getClassLoader(ResourceSet) line: 124
> XcoreEcoreBuilder.getEPackage(XPackage) line: 195
> XcoreModelAssociator.installDerivedState(DerivedStateAwareResource,
> boolean) line: 92
> XcoreResource(DerivedStateAwareResource).installDerivedState(boolean) line: 159
> XcoreResource(BatchLinkableResource).getContents() line: 133
> RegistryReader$EPackageDescriptor$Dynamic.getEPackage() line: 251
> EmfMetamodelDesc.getModel() line: 61
> MetamodelBrowserView$3(MetamodelBrowser).doCreateInput() line: 502
> MetamodelBrowser$5.run() line: 473
> BusyIndicator.showWhile(Display, Runnable) line: 70
> MetamodelBrowserView$3(MetamodelBrowser).createInput() line: 471
> MetamodelBrowserView$3(MetamodelBrowser).<init>(Composite, int)
> line: 168
> MetamodelBrowserView$3(MetamodelBrowser).<init>(Composite) line: 145
> MetamodelBrowserView$3.<init>(MetamodelBrowserView, Composite)
> line: 108
> MetamodelBrowserView.createPartControl(Composite) line: 108
> CompatibilityView(CompatibilityPart).createPartControl(IWorkbenchPart, Composite) line: 141
> CompatibilityView.createPartControl(IWorkbenchPart, Composite)
> line: 155
> CompatibilityView(CompatibilityPart).create() line: 327
> NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line:
> not available [native method]
> NativeMethodAccessorImpl.invoke(Object, Object[]) line: 62
> DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43
> Method.invoke(Object, Object...) line: 483
> MethodRequestor.execute() line: 55
> InjectorImpl.processAnnotated(Class<Annotation>, Object, Class<?>,
> PrimaryObjectSupplier, PrimaryObjectSupplier, ArrayList<Class<?>>) line:
> 888
> InjectorImpl.processAnnotated(Class<Annotation>, Object, Class<?>,
> PrimaryObjectSupplier, PrimaryObjectSupplier, ArrayList<Class<?>>) line:
> 869
> InjectorImpl.inject(Object, PrimaryObjectSupplier,
> PrimaryObjectSupplier) line: 120
> InjectorImpl.internalMake(Class<?>, PrimaryObjectSupplier,
> PrimaryObjectSupplier) line: 337
> InjectorImpl.make(Class<T>, PrimaryObjectSupplier) line: 258
> ContextInjectionFactory.make(Class<T>, IEclipseContext) line: 162
> ReflectionContributionFactory.createFromBundle(Bundle,
> IEclipseContext, IEclipseContext, URI) line: 104
> ReflectionContributionFactory.doCreate(String, IEclipseContext,
> IEclipseContext) line: 73
> ReflectionContributionFactory.create(String, IEclipseContext) line: 55
> ContributedPartRenderer.createWidget(MUIElement, Object) line: 127
> PartRenderingEngine.createWidget(MUIElement, Object) line: 983
> PartRenderingEngine.safeCreateGui(MUIElement, Object,
> IEclipseContext) line: 662
> PartRenderingEngine$6.run() line: 547
> SafeRunner.run(ISafeRunnable) line: 42
> PartRenderingEngine.createGui(MUIElement, Object, IEclipseContext)
> line: 531
> ElementReferenceRenderer.createWidget(MUIElement, Object) line: 69
> PartRenderingEngine.createWidget(MUIElement, Object) line: 983
> PartRenderingEngine.safeCreateGui(MUIElement, Object,
> IEclipseContext) line: 662
> PartRenderingEngine.safeCreateGui(MUIElement) line: 766
> PartRenderingEngine.access$2(PartRenderingEngine, MUIElement) line:
> 737
> PartRenderingEngine$7.run() line: 731
> SafeRunner.run(ISafeRunnable) line: 42
> PartRenderingEngine.createGui(MUIElement) line: 715
> StackRenderer.showTab(MUIElement) line: 1250
> StackRenderer(LazyStackRenderer).postProcess(MUIElement) line: 100
> PartRenderingEngine.safeCreateGui(MUIElement, Object,
> IEclipseContext) line: 678
> PartRenderingEngine.safeCreateGui(MUIElement) line: 766
> PartRenderingEngine.access$2(PartRenderingEngine, MUIElement) line:
> 737
> PartRenderingEngine$7.run() line: 731
> SafeRunner.run(ISafeRunnable) line: 42
> PartRenderingEngine.createGui(MUIElement) line: 715
> SashRenderer(SWTPartRenderer).processContents(MElementContainer<MUIElement>) line: 68
> SashRenderer.processContents(MElementContainer<MUIElement>) line: 185
> PartRenderingEngine.safeCreateGui(MUIElement, Object,
> IEclipseContext) line: 674
> PartRenderingEngine.safeCreateGui(MUIElement) line: 766
> PartRenderingEngine.access$2(PartRenderingEngine, MUIElement) line:
> 737
> PartRenderingEngine$7.run() line: 731
> SafeRunner.run(ISafeRunnable) line: 42
> PartRenderingEngine.createGui(MUIElement) line: 715
> SashRenderer(SWTPartRenderer).processContents(MElementContainer<MUIElement>) line: 68
> SashRenderer.processContents(MElementContainer<MUIElement>) line: 185
> PartRenderingEngine.safeCreateGui(MUIElement, Object,
> IEclipseContext) line: 674
> PartRenderingEngine.safeCreateGui(MUIElement) line: 766
> PartRenderingEngine.access$2(PartRenderingEngine, MUIElement) line:
> 737
> PartRenderingEngine$7.run() line: 731
> SafeRunner.run(ISafeRunnable) line: 42
> PartRenderingEngine.createGui(MUIElement) line: 715
> SashRenderer(SWTPartRenderer).processContents(MElementContainer<MUIElement>) line: 68
> SashRenderer.processContents(MElementContainer<MUIElement>) line: 185
> PartRenderingEngine.safeCreateGui(MUIElement, Object,
> IEclipseContext) line: 674
> PartRenderingEngine.safeCreateGui(MUIElement) line: 766
> PartRenderingEngine.access$2(PartRenderingEngine, MUIElement) line:
> 737
> PartRenderingEngine$7.run() line: 731
> SafeRunner.run(ISafeRunnable) line: 42
> PartRenderingEngine.createGui(MUIElement) line: 715
> PerspectiveRenderer(SWTPartRenderer).processContents(MElementContainer<MUIElement>) line: 68
> PerspectiveRenderer.processContents(MElementContainer<MUIElement>)
> line: 49
> PartRenderingEngine.safeCreateGui(MUIElement, Object,
> IEclipseContext) line: 674
> PartRenderingEngine.safeCreateGui(MUIElement) line: 766
> PartRenderingEngine.access$2(PartRenderingEngine, MUIElement) line:
> 737
> PartRenderingEngine$7.run() line: 731
> SafeRunner.run(ISafeRunnable) line: 42
> PartRenderingEngine.createGui(MUIElement) line: 715
> PerspectiveStackRenderer.showTab(MUIElement) line: 103
> PerspectiveStackRenderer(LazyStackRenderer).postProcess(MUIElement)
> line: 100
> PerspectiveStackRenderer.postProcess(MUIElement) line: 77
> PartRenderingEngine.safeCreateGui(MUIElement, Object,
> IEclipseContext) line: 678
> PartRenderingEngine.safeCreateGui(MUIElement) line: 766
> PartRenderingEngine.access$2(PartRenderingEngine, MUIElement) line:
> 737
> PartRenderingEngine$7.run() line: 731
> SafeRunner.run(ISafeRunnable) line: 42
> PartRenderingEngine.createGui(MUIElement) line: 715
> SashRenderer(SWTPartRenderer).processContents(MElementContainer<MUIElement>) line: 68
> SashRenderer.processContents(MElementContainer<MUIElement>) line: 185
> PartRenderingEngine.safeCreateGui(MUIElement, Object,
> IEclipseContext) line: 674
> PartRenderingEngine.safeCreateGui(MUIElement) line: 766
> PartRenderingEngine.access$2(PartRenderingEngine, MUIElement) line:
> 737
> PartRenderingEngine$7.run() line: 731
> SafeRunner.run(ISafeRunnable) line: 42
> PartRenderingEngine.createGui(MUIElement) line: 715
> WBWRenderer(SWTPartRenderer).processContents(MElementContainer<MUIElement>) line: 68
> WBWRenderer.processContents(MElementContainer<MUIElement>) line: 664
> PartRenderingEngine.safeCreateGui(MUIElement, Object,
> IEclipseContext) line: 674
> PartRenderingEngine.safeCreateGui(MUIElement) line: 766
> PartRenderingEngine.access$2(PartRenderingEngine, MUIElement) line:
> 737
> PartRenderingEngine$7.run() line: 731
> SafeRunner.run(ISafeRunnable) line: 42
> PartRenderingEngine.createGui(MUIElement) line: 715
> PartRenderingEngine$9.run() line: 1078
> Realm.runWithDefault(Realm, Runnable) line: 332
> PartRenderingEngine.run(MApplicationElement, IEclipseContext) line:
> 1032
> E4Workbench.createAndRunUI(MApplicationElement) line: 148
> Workbench$5.run() line: 636
> Realm.runWithDefault(Realm, Runnable) line: 332
> Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 579
> PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 150
> IDEApplication.start(IApplicationContext) line: 135
> EclipseAppHandle.run(Object) line: 196
> EclipseAppLauncher.runApplication(Object) line: 134
> EclipseAppLauncher.start(Object) line: 104
> EclipseStarter.run(Object) line: 380
> EclipseStarter.run(String[], Runnable) line: 235
> NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line:
> not available [native method]
> NativeMethodAccessorImpl.invoke(Object, Object[]) line: 62
> DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43
> Method.invoke(Object, Object...) line: 483
> Main.invokeFramework(String[], URL[]) line: 648
> Main.basicRun(String[]) line: 603
> Main.run(String[]) line: 1465
> Main.main(String[]) line: 1438
>
>
> These 2 threads are trying to register the same EPackage: xcore.lang
>
> The NPE is caused by the fact that the ResourceSet's resources contains
> a NULL!
>
>
> for (Resource resource : resourceSet.getResources())
> {
> URI uri = resource.getURI(); // NPE because resource is null!
> ...
> }
>
>
> There was a misleading NPE that turns out to be a minor vulnerability in
> the EMF RegistryReader:
>
>
> diff --git
> a/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/plugin/RegistryReader.java
> b/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/plugin/RegistryReader.java
>
> index 9666a50..bf098c3 100644
> ---
> a/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/plugin/RegistryReader.java
>
> +++
> b/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/plugin/RegistryReader.java
>
> @@ -24,9 +24,11 @@ import org.eclipse.core.runtime.IExtensionRegistry;
> import org.eclipse.core.runtime.IRegistryChangeEvent;
> import org.eclipse.core.runtime.IRegistryChangeListener;
> import org.eclipse.emf.common.CommonPlugin;
> +import org.eclipse.emf.common.util.EList;
> import org.eclipse.emf.common.util.URI;
> import org.eclipse.emf.common.util.WrappedException;
> import org.eclipse.emf.ecore.EFactory;
> +import org.eclipse.emf.ecore.EObject;
> import org.eclipse.emf.ecore.EPackage;
> import org.eclipse.emf.ecore.EcorePackage;
> import org.eclipse.emf.ecore.resource.Resource;
> @@ -244,7 +246,11 @@ public abstract class RegistryReader
> }
> else
> {
> - return (EPackage)
> EcoreUtil.getObjectByType(resourceSet.getResource(locationURI,
> true).getContents(), EcorePackage.Literals.EPACKAGE);
> + Resource r = resourceSet.getResource(locationURI, true);
> + if (r != null)
> + return (EPackage)
> EcoreUtil.getObjectByType(r.getContents(), EcorePackage.Literals.EPACKAGE);
> + else
> + throw new RuntimeException("No EPackage found at: "
> + locationURI);
> }
> }
> else
>
>
> Basically, the original code assumes that resourceSet.getResource(...)
> never returns null. AFAIK, there is no such guarantee at the point in
> the logic.
>
> With this NPE vulnerability aside, we are left with the problem: how
> could a ResourceSet have a null resource?
>
> This should not happen but it obviously does in this case.
>
> The problem is really due to concurrent calls to
> ResourceSet.add(Resource) because the default implementation (i.e.
> ResourceSetImpl) is not thread-safe for concurrent modification.
> I managed to work around the problem by synchronizing calls to
> ResourceSetImpl::add(Resource):
>
>
> diff --git
> a/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/resource/impl/ResourceSetImpl.java
> b/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/resource/impl/ResourceSetImpl.java
>
> index 6f896e8..9792542 100644
> ---
> a/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/resource/impl/ResourceSetImpl.java
>
> +++
> b/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/resource/impl/ResourceSetImpl.java
>
> @@ -432,7 +432,9 @@ public class ResourceSetImpl extends NotifierImpl
> implements ResourceSet
> if (resourceFactory != null)
> {
> Resource result = resourceFactory.createResource(uri);
> - getResources().add(result);
> + if (result != null) {
> + getResources().add(result);
> + }
> return result;
> }
> else
> @@ -609,6 +611,14 @@ public class ResourceSetImpl extends NotifierImpl
> implements ResourceSet
> {
> return size <= 4 ? super.contains(object) : object instanceof
> Resource && ((Resource)object).getResourceSet() == ResourceSetImpl.this;
> }
> +
> + @Override
> + public boolean add(E object) {
> + synchronized(this) {
> + return super.add(object);
> + }
> + }
> + }
>
>
> The evidence that this workaround is effective is that if I comment out
> the synchronized guard in the call to super.add(object), then I get NPEs
> on 2 threads at initialization.
> Has anyone encountered this problem before?
>
> Is there a test case that involves plugins that register dynamic
> metamodels?
>
> If yes, I'd like to see if I can reproduce this problem in a simpler
> environment by opening the Eclipse QVTO metamodel registry view and an
> Eclipse QVTO editor.
> This seems to be enough to concurrent threads that will initialize the
> EMF EPackage registry and therefore force adding metamodel resources to
> the same ResourceSet.
>
> On the other hand, it is rather interesting that these NPEs have
> systematically happened during the initialization of XCore even though
> the examples I made do not involve XCore's metamodels (except for the
> Eclipse QVTO Metamodel Registry view which shows all registered
> metamodels -- static & dynamic)
>
> - Nicolas.
Forum: Newcomers
 Topic: Customizing makefile via environment variable
Re: Customizing makefile via environment variable [message #1518585 is a reply to message #1517311] Sat, 20 December 2014 05:46
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3266
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 12/19/2014 06:27 AM, Andrey Solovjev wrote:
> I'd like to have different compile options in my own makefile when I use
> different build configurations. I try to define an environment variable
> to use it in the makefile. After I add the variable I see it in the list
> of variables with the origin USER: CONFIG. Press "Apply" and "Ok". Then
> I press "build project". In the makefile my variable name in undefined.
> More, after project building the variable disappears from the
> environment list in the project properties. Please, prompt me the right
> way to customize my build options in the external makefile. Eclipse
> Luna, CDT.

Eclipse CDT has its own forum. Post there.
 Topic: Eclipse will not work
Unable to locate executable for jre1.8.0_25 [message #1518222 is a reply to message #1468040] Sat, 20 December 2014 00:52
Doyle Fouquet is currently offline Doyle FouquetFriend
Messages: 1
Registered: December 2014
Junior Member
That's great. This is my first time on here. I know nothing about Sticky notes or where to find them. How about an answer to the question, how do I get around the problem of "Unable to locate executable for jre1.8.0_25"?
Re: Unable to locate executable for jre1.8.0_25 [message #1518993 is a reply to message #1518222] Sat, 20 December 2014 11:23
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 2342
Registered: July 2009
Senior Member
Probably needs its own thread--it's a different message altogether.

---
Nitin Dahyabhai
Eclipse WTP, IBM
Forum: EMF "Technology" (Ecore Tools, EMFatic, etc)
 Topic: [EMFForms] Application Menu in a Treeview with CNF
Re: [EMFForms] Application Menu in a Treeview with CNF [message #1519012 is a reply to message #1517416] Sat, 20 December 2014 11:38
Jonas Helming is currently offline Jonas HelmingFriend
Messages: 504
Registered: July 2009
Senior Member
Hi,

I am not sure whether CNF is of much help, but that depends on the
features your tree needs to support.
EMF provides a lot of helper classes and generated adapters to very
efficiently implement a tree viewer youself. You can use the model
explorer of the EMF Client Platform as a start (either extend it or look
at its implementation)

Best regards

Jonas

--
Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/

Am 19.12.2014 14:32, schrieb Michael Kolowicz:
> I want to create a prototy of a new application. The navigation of the
> functions should be done by a Explorer like UI. On the left side is a
> treeview with the menu. On the right side I habe the Details or lists of
> the relevant data.
>
> The explorer-tree should be shown as example below
>
> MyPrototy
> + Settings
> ! + Printer
> ! + Users
> + ModuleA
> ! + DataEntries
> ! + View Entries
> ! + Manage Entries
> ! + Print Entries
> + ModuleB
> ! + ...............
>
>
> Is CNF (Common Navigation Framework) the right way? How can I use it in
> a e4 application?
>
> I found some tutorials, but the problem is, that i dont know so much
> about the EMF that I can put in in my application. My problem is often
> which references must be in which package/project. And how can I create
> the needed "views" (like
> h**p://andydunkel.net/eclipse/rcp/2014/05/24/introduction_to_cnf.html -
> what mean the part "The next step is to add the view to the project by
> adding it to the org.eclipse.ui.views extension point". What is the
> right place and how can i do it?)
>
> Thanks for your help


--
Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Forum: scout
 Topic: If you try the developer preview version Mars M4
If you try the developer preview version Mars M4 [message #1518839] Sat, 20 December 2014 09:16
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 818
Registered: October 2011
Senior Member
If you try our latest developer preview version (Mars M4), you might get a lot of errors when you click in the Tree in the Scout Explorer.

An internal error occurred during: "calculating java doc of X".

index.php/fa/20264/0/

This bug has already been fixed; you just need to update your SDK:
Help > Install New Software...

Use the update site:
http://download.eclipse.org/scout/nightly


index.php/fa/20265/0/

Select "Eclipse Scout SDK". Click twice on „Next >", accept the license and click on finish. Wait for the install and restart your IDE when you are asked to do so.

[Updated on: Sat, 20 December 2014 09:17]

Report message to a moderator

 Topic: TableField as template?
TableField as template? [message #1519025] Sat, 20 December 2014 11:49
Flash Man is currently offline Flash ManFriend
Messages: 17
Registered: August 2014
Junior Member
I am using the tablefiled to show data more than once, is it possible to make it as template, and use it..?



Current Time: Sat Dec 20 14:27:54 GMT 2014

Powered by FUDForum. Page generated in 0.02568 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software