Skip to content

Commit 54ba9f2

Browse files
committed
Fix review comments
1. Fix race condition in the get method 2. Remove spotbugs exclusions that were copy pasted Signed-off-by: Mahesh Patil <maheshfinity@gmail.com>
1 parent db61db1 commit 54ba9f2

2 files changed

Lines changed: 9 additions & 46 deletions

File tree

providers/gcp-parameter-manager/spotbugs-exclusions.xml

Lines changed: 0 additions & 39 deletions
This file was deleted.

providers/gcp-parameter-manager/src/main/java/dev/openfeature/contrib/providers/gcpparametermanager/FlagCache.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@ class FlagCache {
2222
FlagCache(Duration ttl, int maxSize) {
2323
this.ttl = ttl;
2424
this.store = Collections.synchronizedMap(
25-
new LinkedHashMap<String, CacheEntry>(16, 0.75f, false) {
26-
@Override
27-
protected boolean removeEldestEntry(Map.Entry<String, CacheEntry> eldest) {
28-
return size() > maxSize;
29-
}
30-
});
25+
new LinkedHashMap<String, CacheEntry>(16, 0.75f, false) {
26+
@Override
27+
protected boolean removeEldestEntry(Map.Entry<String, CacheEntry> eldest) {
28+
return size() > maxSize;
29+
}
30+
}
31+
);
3132
}
3233

3334
/**
@@ -42,7 +43,7 @@ Optional<String> get(String key) {
4243
return Optional.empty();
4344
}
4445
if (entry.isExpired()) {
45-
store.remove(key);
46+
store.remove(key, entry);
4647
return Optional.empty();
4748
}
4849
return Optional.of(entry.value);
@@ -74,6 +75,7 @@ void clear() {
7475
}
7576

7677
private static final class CacheEntry {
78+
7779
final String value;
7880
final Instant expiresAt;
7981

0 commit comments

Comments
 (0)