Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Compare » NPE in ComparisonUtil.isContainedInFeatureMap(When comparing two EMF models programmatically, I am getting NPEs from ComparisonUtil.IsContainedInFeatureMap)
NPE in ComparisonUtil.isContainedInFeatureMap [message #1766826] Tue, 27 June 2017 16:42 Go to next message
Klaus Birken is currently offline Klaus BirkenFriend
Messages: 1
Registered: September 2015
Junior Member

when switching from EMFCompare 3.0.1 to 3.2.1, I am getting NPEs in ComparisonUtil.isContainedInFeatureMap. I attached the NPE below.

The direct cause seems to be that in the first line of code in the body

public static boolean isContainedInFeatureMap(EObject object) {
		final EAnnotation annotation = object.eContainingFeature()

the compared object doesn't have a containing feature (it's the root object of the model). It seems this code has been introduced in 3.1.0.

Probably our way of starting the comparison is wrong (for 3.1.0 and later), here is a snippet:

IComparisonScope scope = EMFCompare.createDefaultScope(rset1, rset2);
Comparison comparison = EMFCompare.builder().build().compare(scope);

I could fix my specific issue by reverting to EMFCompare 3.0.1, but maybe it is a real bug and should be fixed (and we could keep using head).



Re: NPE in ComparisonUtil.isContainedInFeatureMap [message #1767007 is a reply to message #1766826] Thu, 29 June 2017 13:14 Go to previous message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1897
Registered: July 2009
Senior Member

This sounds and looks like a bug. We're checking if the object is contained within an annotation so I guess not having a containment feature also means that it's not contained within an annotation :). It would be easy to add a null check to avoid the exception, but that won't be enough if there are more bugs related to the same assumption later in the code. would you be able to provide us with a reproduction sample on bugzilla?

Laurent Goubet
Previous Topic:Group Differences
Next Topic:Closing EMF compare dialog after conflict resolution gets stuck
Goto Forum:

Current Time: Sat Jul 02 03:14:32 GMT 2022

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

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

Back to the top