[EMF Compare]MatchEngine NPE bug [message #617985] |
Fri, 02 May 2008 15:41 |
David Michonneau Messages: 85 Registered: July 2009 |
Member |
|
|
Hi,
It seems there is a bug in the GenericMatchEngine.hasSameUri() code:
if one of the EObject returns an empty eResource() (which happens for some
objects in my model), it throws a NPE. I suggest the following fix below.
Thanks,
David
/**
* Checks wether the two given {@link EObject} have the same URI.
*
* @param obj1
* First of the two {@link EObject} we're comparing.
* @param obj2
* Second {@link EObject} we're comparing.
* @return <code>True</code> if the {@link EObject}s have the same URI,
<code>False</code> otherwise.
*/
private boolean hasSameUri(EObject obj1, EObject obj2) {
if ( obj1.eResource() == obj2.eResource() ) // null==null returns true
return true;
if ( obj1.eResource() == null || obj2.eResource() == null ) // if one of
them is null and not the other return false
return false;
return
obj1.eResource().getURIFragment(obj1).equals(obj2.eResource( ).getURIFragment(obj2));
}
|
|
|
Powered by
FUDForum. Page generated in 0.03266 seconds