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 could let us know whether this is a bug or whether
it is a valid behavior of the cache.

Another problem that we have found is that longterm is a WeakHashMap which
is not a thread safe implementation and there exists a trace that many
threads run this.longterm.putAll(this.eden); concurrently.



Thanks,

Ohad

Reply via email to