Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8221454

treeifyBin method will resize table size to 3 times bigger

    Details

      Description

      ADDITIONAL SYSTEM INFORMATION :
      Generic

      A DESCRIPTION OF THE PROBLEM :
      java.util.concurrent.ConcurrentHashMap.java :
      In following code, calling tryPresize(n << 1) will make the table length resize to 3 times bigger, but it should be 2 times after resizing.
      private final void treeifyBin(Node<K,V>[] tab, int index) {
              Node<K,V> b; int n, sc;
              if (tab != null) {
                  if ((n = tab.length) < MIN_TREEIFY_CAPACITY)
                      tryPresize(n << 1);
                  else if ((b = tabAt(tab, index)) != null && b.hash >= 0) {
                      synchronized (b) {
                          if (tabAt(tab, index) == b) {
                              TreeNode<K,V> hd = null, tl = null;
                              for (Node<K,V> e = b; e != null; e = e.next) {
                                  TreeNode<K,V> p =
                                      new TreeNode<K,V>(e.hash, e.key, e.val,
                                                        null, null);
                                  if ((p.prev = tl) == null)
                                      hd = p;
                                  else
                                      tl.next = p;
                                  tl = p;
                              }
                              setTabAt(tab, index, new TreeBin<K,V>(hd));
                          }
                      }
                  }
              }
          }



      FREQUENCY : always


        Attachments

          Activity

            People

            • Assignee:
              dl Doug Lea
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated: