Uploaded image for project: 'XalanJ2'
  1. XalanJ2
  2. XALANJ-990

QName.hashCode() inconsistent with QName.equals(Object)

Agile BoardAttach filesAttach ScreenshotAdd voteVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 2.4
    • None
    • Other
    • None
    • Operating System: All
      Platform: All
    • 8783

    Description

      Part of the general contract of hashCode() method is that "If two objects are
      equal according to the equals(Object) method, then calling the hashCode method
      on each of the two objects must produce the same integer result."
      Unfortunately, this is not true for org.apache.xml.utils.QName. In fact,
      QName.hashCode() is a function of its prefix, its namespace and its local name
      whereas QName.equals(Object) is just a function of its namespace and local
      name. This means that two QNames which differ only by their prefixes would be
      considered equal but their hashCode values would be different( e.g. new QName
      ("http://examples.org","a", "example") and new QName
      ("http://examples.org","b", "example").
      This inconsistency could lead to serious bugs if QNames are used as keys of
      hash maps.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            achille@us.ibm.com Achille Fokoue

            Dates

              Created:
              Updated:

              Slack

                Issue deployment