Hello team!
I just found a problem using com.google.common.hash.BloomFilter with more than one thread. Long story short: put() is not atomic so I am able to reproduce a false negative.
This is the config in pom.xml:
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>24.0-jre</version>
</dependency>
I created a simple Test.java class that proves the point. The fix is also included in the file: just uncomment lines 56 and 58 (make put() synchronized).
Looking at the BloomFilter javadoc I see:
* As of Guava 23.0, this class is thread-safe and lock-free. It internally uses atomics and
* compare-and-swap to ensure correctness when multiple threads are used to access it.
So I suppose that I'm not doing anything "wrong". Can you please confirm the issue or tell me where I'm using the library wrong?
Thanks!
Hello team!
I just found a problem using
com.google.common.hash.BloomFilterwith more than one thread. Long story short:put()is not atomic so I am able to reproduce a false negative.This is the config in
pom.xml:I created a simple Test.java class that proves the point. The fix is also included in the file: just uncomment lines 56 and 58 (make
put()synchronized).Looking at the
BloomFilterjavadoc I see:So I suppose that I'm not doing anything "wrong". Can you please confirm the issue or tell me where I'm using the library wrong?
Thanks!