Uploaded image for project: 'Hadoop Common'
  1. Hadoop Common
  2. HADOOP-11221

JAVA specification for hashcode does not enforce it to be non-negative, but IdentityHashStore assumes System.identityHashCode() is non-negative

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4.1
    • 2.6.0
    • util
    • None
    • Reviewed

    Description

      The following code snippet shows that IdentityHashStore assumes the hashCode is always non-negative.

         private void putInternal(Object k, Object v) {
           int hash = System.identityHashCode(k);
           final int numEntries = buffer.length / 2;
           int index = hash % numEntries;
      	 ...
         }
         
        private int getElementIndex(K k) {
           ...
           final int numEntries = buffer.length / 2;
           int hash = System.identityHashCode(k);
           int index = hash % numEntries;
           int firstIndex = index;
           ...
        }
      

      Attachments

        1. HADOOP-11221.patch
          1.0 kB
          Jinghui Wang
        2. HADOOP-11221.v1.patch
          1 kB
          Jinghui Wang
        3. HADOOP-11221.v2.patch
          1 kB
          Jinghui Wang
        4. HADOOP-11221.v3.patch
          1 kB
          Jinghui Wang

        Activity

          People

            jwang302 Jinghui Wang
            jwang302 Jinghui Wang
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: