Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Compare » [Bug?] NPE during comparison of EObjects
[Bug?] NPE during comparison of EObjects [message #1282451] Wed, 02 April 2014 10:24 Go to next message
Florian Zoubek is currently offline Florian ZoubekFriend
Messages: 1
Registered: April 2014
Junior Member
Hello everyone,

I'm trying to compare two EObjects (more precisely two DynamicEObjects) with EMF Compare 3.0.1 and I'm always getting the following NullPointerException:

java.lang.NullPointerException
	at org.eclipse.emf.compare.scope.FilterComparisonScope.addUri(FilterComparisonScope.java:194)
	at org.eclipse.emf.compare.scope.FilterComparisonScope$URIInitializingIterator.<init>(FilterComparisonScope.java:255)
	at org.eclipse.emf.compare.scope.FilterComparisonScope.getChildren(FilterComparisonScope.java:127)
	at org.eclipse.emf.compare.match.DefaultMatchEngine.match(DefaultMatchEngine.java:304)
	at org.eclipse.emf.compare.match.DefaultMatchEngine.match(DefaultMatchEngine.java:121)
	at org.eclipse.emf.compare.match.DefaultMatchEngine.match(DefaultMatchEngine.java:91)
	at org.eclipse.emf.compare.EMFCompare.compare(EMFCompare.java:163)
	at org.eclipse.emf.compare.EMFCompare.compare(EMFCompare.java:146)
	at at.bitandart.zoubek.statespace.vis.emf.model.impl.EMFCompareHistoryBuilderImpl.compare(EMFCompareHistoryBuilderImpl.java:550)
...


My code that invokes the comparison looks like this:

	private Comparison compare(Notifier left,
			Notifier right) { 

		// Configure EMF Compare
		IEObjectMatcher matcher = DefaultMatchEngine.createDefaultEObjectMatcher(UseIdentifiers.WHEN_AVAILABLE);
		IComparisonFactory comparisonFactory = new DefaultComparisonFactory(new DefaultEqualityHelperFactory());
		IMatchEngine.Factory matchEngineFactory = new MatchEngineFactoryImpl(	matcher,
																				comparisonFactory);
		matchEngineFactory.setRanking(20);
		IMatchEngine.Factory.Registry matchEngineRegistry = new MatchEngineFactoryRegistryImpl();
		matchEngineRegistry.add(matchEngineFactory);
		EMFCompare comparator = EMFCompare.builder()
											.setMatchEngineFactoryRegistry(matchEngineRegistry)
											.build();

		// Compare the two models
		IComparisonScope scope = EMFCompare.createDefaultScope(	left,
																right);
		return comparator.compare(scope);
	}

The right EObject is contained in a ResultSet, the left one is not contained in a ResultSet. Is this a bug or is there something I'm doing wrong?

I know it would be great if I could provide an example to reproduce the problem but I'm not sure how to do that as the model instances are provided through an third party plugin at runtime (and I'm relatively new to EMF & EMF Compare).

Thanks in advance,

Florian Zoubek
Re: [Bug?] NPE during comparison of EObjects [message #1283353 is a reply to message #1282451] Thu, 03 April 2014 10:20 Go to previous message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
Hi Florian,

If you use a Resource, we expect it to have a valid URI.

You usually create Resources through ResourceSet.createResource(...) or ResourceSet.getResource(...). Please make sure you do not use the "new ResourceImpl()" constuctor or that you immediately set its URI to a valid value (resource.setURI(...)).

Laurent Goubet
Obeo
Previous Topic:Best way to combine two attribute changes into a high-level atomic one
Next Topic:Compatibility of version 3?
Goto Forum:
  


Current Time: Fri Mar 29 10:19:01 GMT 2024

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

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

Back to the top