You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@uima.apache.org by "Adam Lally (JIRA)" <ui...@incubator.apache.org> on 2007/11/30 20:24:43 UTC

[jira] Closed: (UIMA-534) The equals() method in MetaDataObject_impl doesn't compare elements in a Map properly.

     [ https://issues.apache.org/jira/browse/UIMA-534?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Adam Lally closed UIMA-534.
---------------------------


sanity check complete.  Marshall passes. :)

> 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
>            Assignee: Adam Lally
>            Priority: Minor
>             Fix For: 2.2.1
>
>
> 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.