Hi,


We are writing a tool to detect atomicity violations in usage of
ConcurrentHashMap.

We have run the tool that reported an atomicity violation in functions get
and put of class ConcurrentCache.

The following code shows the put function of the ConcurrentCache:



    public void put(K k, V v) {

        if (this.eden.size() >= size) {

            this.longterm.putAll(this.eden);

            this.eden.clear();

        }

        this.eden.put(k, v);

    }



In this code the tool discovered a scenario that a (k,v) pair is added to
eden and a clear operation deletes this pair without copying it to the
longterm hash.

We would be happy if you can let us know if this is a bug or this is a valid
behavior of the cache.

Another problem is that longterm is a WeakHashMap which is not a thread safe
implementation.



Thanks,

Ohad

Reply via email to