Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P4
    • 10
    • Affects Version/s: None
    • Component/s: security-libs
    • None

      The hashCode() doesn't depend on the relative order of the bytes in the underlying array.

          Cache.EqualByteArray a1 = new Cache.EqualByteArray(new byte[] {1,2,3});
          Cache.EqualByteArray a2 = new Cache.EqualByteArray(new byte[] {2,3,1});
          Cache.EqualByteArray a3 = new Cache.EqualByteArray(new byte[] {3,1,2});
          System.out.println(a1.hashCode());
          System.out.println(a2.hashCode());
          System.out.println(a3.hashCode());

      Prints
      226
      226
      226

      It may be better to use Arrays.hashCode(byte[]).

            Assignee:
            Ivan Gerasimov
            Reporter:
            Ivan Gerasimov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: