[Bug?] NPE during comparison of EObjects [message #1282451] |
Wed, 02 April 2014 06:24  |
Eclipse User |
|
|
|
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 06:20  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.03779 seconds