Jianlin Shi created UIMA-5813:
---------------------------------
Summary: MetaDataObject_impl doesn't compare
CasProcessorConfigurationParameterSettings when the "equals" is called
Key: UIMA-5813
URL: https://issues.apache.org/jira/browse/UIMA-5813
Project: UIMA
Issue Type: Bug
Components: UIMA
Affects Versions: 3.0.0SDK, 2.10.2SDK, 2.10.0SDK, 2.10.3SDK
Reporter: Jianlin Shi
In org.apache.uima.resource.metadata.impl.MetaDataObject_impl
The method:
{color:#cc7832}public boolean
{color}{color:#ffc66d}equals{color}{color:#9876aa}({color}Object
aObj{color:#9876aa}) {color}
{color:#333333}calls another method:{color}{color:#9876aa}
{color}
{color:#cc7832}private boolean
{color}{color:#ffc66d}valuesEqual{color}{color:#9876aa}({color}Object
val1{color:#cc7832}, {color}Object val2{color:#9876aa})
{color}
However, in "valuesEqual", the CasProcessorConfigurationParameterSettings is
never compared.
Suggest to add the following in valuesEqual method:
{quote} if (val1 instanceof
CasProcessorConfigurationParameterSettingsImpl) {// only need this to handle
Maps w/ array vals
if (!(val2 instanceof
CasProcessorConfigurationParameterSettingsImpl)) {
return false;
}
CasProcessorConfigurationParameterSettingsImpl settings1 =
(CasProcessorConfigurationParameterSettingsImpl) val1;
CasProcessorConfigurationParameterSettingsImpl settings2 =
(CasProcessorConfigurationParameterSettingsImpl) val2;
if (settings1.getParameterSettings().length !=
settings2.getParameterSettings().length) {
return false;
}
if (settings1.getParameterSettings().length >=
settings2.getParameterSettings().length) {
Map<String, Object> values2 = new HashMap<>();
for (NameValuePair pair : settings2.getParameterSettings()) {
values2.put(pair.getName(), pair.getValue());
}
for (NameValuePair pair : settings1.getParameterSettings()) {
if (values2.containsKey(pair.getName())
&&
!values2.get(pair.getName()).equals(pair.getValue())) {
return false;
}
values2.remove(pair.getName());
}
if (values2.size() > 0)
return false;
} else {
Map<String, Object> values1 = new HashMap<>();
for (NameValuePair pair : settings1.getParameterSettings()) {
values1.put(pair.getName(), pair.getValue());
}
for (NameValuePair pair : settings2.getParameterSettings()) {
if (values1.containsKey(pair.getName())
&&
values1.get(pair.getName()).equals(pair.getValue())) {
return false;
}
values1.remove(pair.getName());
}
if (values1.size() > 0)
return false;
}
return true;
}
{quote}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)