Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
2.1, 2.2
-
None
Description
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)
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))