File tree Expand file tree Collapse file tree 2 files changed +8
-8
lines changed
main/java/io/split/client/impressions
test/java/io/split/client/impressions Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change 33import com .google .common .cache .Cache ;
44import com .google .common .cache .CacheBuilder ;
55import io .split .client .dtos .KeyImpression ;
6+ import org .apache .http .annotation .NotThreadSafe ;
67
78/*
89According to guava's docs (https://guava.dev/releases/18.0/api/docs/com/google/common/annotations/Beta.html),
1213 */
1314
1415@ SuppressWarnings ("UnstableApiUsage" )
16+ @ NotThreadSafe
1517public class ImpressionObserver {
1618
1719 private final Cache <Long , Long > _cache ;
1820
1921 public ImpressionObserver (long size ) {
2022 _cache = CacheBuilder .newBuilder ()
2123 .maximumSize (size )
24+ .concurrencyLevel (4 ) // Just setting the default value explicitly
2225 .build ();
2326 }
24-
27+
2528 public Long testAndSet (KeyImpression impression ) {
2629 if (null == impression ) {
2730 return null ;
2831 }
2932
3033 Long hash = ImpressionHasher .process (impression );
31-
32- synchronized (this ) {
33- Long previous = _cache .getIfPresent (hash );
34- _cache .put (hash , impression .time );
35- return previous ;
36- }
34+ Long previous = _cache .getIfPresent (hash );
35+ _cache .put (hash , impression .time );
36+ return previous ;
3737 }
3838}
Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ public void doesNotCrash() {
6767
6868 imp1 .treatment = null ;
6969 assertNotNull (ImpressionHasher .process (imp1 ));
70-
70+
7171 assertNull (ImpressionHasher .process (null ));
7272 }
7373}
You can’t perform that action at this time.
0 commit comments