Uploaded image for project: 'UIMA'
  1. UIMA
  2. UIMA-5813

MetaDataObject_impl doesn't compare CasProcessorConfigurationParameterSettings when the "equals" is called

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Implemented
    • 2.10.0SDK, 2.10.2SDK, 3.0.0SDK, 2.10.3SDK
    • None
    • UIMA
    • None

    Description

      In org.apache.uima.resource.metadata.impl.MetaDataObject_impl

      The method:

      public boolean equals(Object aObj)

      calls another method:

      private boolean valuesEqual(Object val1, Object val2)

      However, in "valuesEqual", the CasProcessorConfigurationParameterSettings is never compared.

      Suggest to add the following in valuesEqual method:

              if (val1 instanceof CasProcessorConfigurationParameterSettingsImpl) {// only need this to handle Maps w/ array vals
                  if (!(val2 instanceof CasProcessorConfigurationParameterSettingsImpl))

      Unknown macro: {                 return false;             }

                  CasProcessorConfigurationParameterSettingsImpl settings1 = (CasProcessorConfigurationParameterSettingsImpl) val1;
                  CasProcessorConfigurationParameterSettingsImpl settings2 = (CasProcessorConfigurationParameterSettingsImpl) val2;
                  if (settings1.getParameterSettings().length != settings2.getParameterSettings().length)

                  if (settings1.getParameterSettings().length >= settings2.getParameterSettings().length) {
                      Map<String, Object> values2 = new HashMap<>();
                      for (NameValuePair pair : settings2.getParameterSettings())

      Unknown macro: {                     values2.put(pair.getName(), pair.getValue());                 }

                      for (NameValuePair pair : settings1.getParameterSettings()) {
                          if (values2.containsKey(pair.getName())
                                  && !values2.get(pair.getName()).equals(pair.getValue()))

      Unknown macro: {                         return false;                     }

                          values2.remove(pair.getName());
                      }
                      if (values2.size() > 0)
                          return false;
                  } else {
                      Map<String, Object> values1 = new HashMap<>();
                      for (NameValuePair pair : settings1.getParameterSettings())

      Unknown macro: {                     values1.put(pair.getName(), pair.getValue());                 }

                      for (NameValuePair pair : settings2.getParameterSettings()) {
                          if (values1.containsKey(pair.getName())
                                  && values1.get(pair.getName()).equals(pair.getValue()))

                          values1.remove(pair.getName());
                      }
                      if (values1.size() > 0)
                          return false;
                  }
                  return true;
              }

       

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            jianlins Jianlin Shi
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: