For embedded $regex, BasicBSONObject hashCode() output is not consistent with equals()

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Duplicate
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      See https://jira.mongodb.org/browse/JAVA-1078?focusedCommentId=485029&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-485029

      Revised test case:

              SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
              BasicBSONObject a = new BasicBSONObject("ts", sdf.parse("2014-01-03T13:16:03.359Z"));
              BasicBSONObject b = new BasicBSONObject("ts", sdf.parse("2014-01-03T13:16:03.359Z"));
              assertTrue(a.equals(b));
              assertTrue(a.hashCode() == b.hashCode());
      
              a = new BasicBSONObject("firstName", Pattern.compile("^asdf"));
              b = new BasicBSONObject("firstName", Pattern.compile("^asdf"));
              assertTrue(a.equals(b));
              assertTrue(a.hashCode() == b.hashCode());
      

              Assignee:
              Unassigned
              Reporter:
              Stephen Lee (Inactive)
              None
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: