Uploaded image for project: 'Hadoop HDFS'
  1. Hadoop HDFS
  2. HDFS-16798

SerialNumberMap should decrease current counter if the item exist

    XMLWordPrintableJSON

Details

    • Reviewed

    Description

      During looking into some code related XATTR, I found there is a bug in SerialNumberMap, as bellow:

      public int get(T t) {
        if (t == null) {
          return 0;
        }
        Integer sn = t2i.get(t);
        if (sn == null) {
          sn = current.getAndIncrement();
          if (sn > max) {
            current.getAndDecrement();
            throw new IllegalStateException(name + ": serial number map is full");
          }
          Integer old = t2i.putIfAbsent(t, sn);
          if (old != null) {
            // here: if the old is not null, we should decrease the current value.
            return old;
          }
          i2t.put(sn, t);
        }
        return sn;
      } 

      This bug will only cause that the capacity of serialNumberMap is less than expected, no other impact.

      Attachments

        Issue Links

          Activity

            People

              xuzq_zander ZanderXu
              xuzq_zander ZanderXu
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: