The equals() method in MetaDataObject_impl doesn't compare elements in a Map
properly.
--------------------------------------------------------------------------------------
Key: UIMA-534
URL: https://issues.apache.org/jira/browse/UIMA-534
Project: UIMA
Issue Type: Bug
Components: Core Java Framework
Affects Versions: 2.1, 2.2
Reporter: Danai Wiriyayanyongsuk
Priority: Minor
In the class org.apache.uima.resource.metadata.impl.MetaDataObject_impl, the
equals() method returns immediately with the comparison result of the first Map
elements, leaving the rest of the Map's element uncompared.
Here is the code snippet:
while (it.hasNext()) {
Map.Entry entry = (Map.Entry) it.next();
Object subval1 = ((Map) val1).get(entry.getKey());
Object subval2 = ((Map) val2).get(entry.getKey());
if (subval1 == null) {
if (subval2 != null)
return false;
} else if (subval1 instanceof Object[]) {
if (!(subval2 instanceof Object[]))
return false;
if (!Arrays.equals((Object[]) subval1, (Object[]) subval2))
return false;
line:443 } else
line:444 return subval1.equals(subval2);
}
The problem with the code is that the statement line 444 will return the result
immediately, causing the while loop to be quit without comparing the rest of
elements in the Map.
To fix this, one could replace line 443 and 444 with the following:
} else if (!(subval1.equals(subval2)) {
return false;
}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.