Koloboke icon indicating copy to clipboard operation
Koloboke copied to clipboard

Field removedSlots cleared too early in rehash

Open niemisto opened this issue 7 years ago • 0 comments

I noticed the following problem in rehash implementation, at least in MutableObjQHashSetSO.

    void rehash(int newCapacity) {
        int mc = modCount();
        Object[] keys = set;
        initForRehash(newCapacity);
        mc++; // modCount is incremented in initForRehash()
        Object[] newKeys = set;
        int capacity = newKeys.length;
        if (noRemoved()) {
            ...

The method initForRehash calls internalInit that calls initSlotCounts that sets removedSlots to zero. Therefore the test noRemoved() always succeeds even when the hash set contains REMOVED entries. This bug appears in koloboke-impl-jdk8 1.0.0 I downloaded from Maven central.

niemisto avatar Oct 27 '16 09:10 niemisto