Uploaded image for project: 'OpenNLP'
  1. OpenNLP
  2. OPENNLP-1471

Ensure Dictionary#asStringSet() implements hashCode() and equals() correctly

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.1.0, 2.1.1
    • 2.2.0
    • None
    • None

    Description

      The tests  (a)  DictionaryAsSetCaseInsensitiveTest and 
      (b) DictionaryAsSetCaseSensitiveTest have an open TODO that points to a bug in Dictionary#asStringSet()
       

      // TODO: should it be equal??
      Assertions.assertNotSame(setA.hashCode(), setB.hashCode());

      To cure this, the implementation of Dictionary#asStringSet() needs override hashCode and equals properly.

      After fixing the implementation, the following assertion must hold:

      Assertions.assertEquals(setA, setB);

      Assertions.assertEquals(setA.hashCode(), setB.hashCode());

      where setA and setB are obtained via Dictionary#asStringSet().

      Attachments

        Activity

          People

            mawiesne Martin Wiesner
            mawiesne Martin Wiesner
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: