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

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.4.1
    • Fix Version/s: 2.6.0
    • Component/s: util
    • Labels:
      None
    • Hadoop Flags:
      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.v3.patch
          1 kB
          Jinghui Wang
        2. HADOOP-11221.v2.patch
          1 kB
          Jinghui Wang
        3. HADOOP-11221.v1.patch
          1 kB
          Jinghui Wang
        4. HADOOP-11221.patch
          1.0 kB
          Jinghui Wang

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: