Skip to content

Commit a3fa786

Browse files
Bugfix: Use a thread-safe version of the map for caching the MongoCollection handle (#219)
1 parent c2eec6d commit a3fa786

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

document-store/src/main/java/org/hypertrace/core/documentstore/mongo/collection/MongoCollectionOptionsApplier.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
import com.mongodb.BasicDBObject;
77
import com.mongodb.ReadPreference;
88
import com.mongodb.client.MongoCollection;
9-
import java.util.HashMap;
109
import java.util.Map;
10+
import java.util.concurrent.ConcurrentHashMap;
1111
import lombok.Builder;
1212
import lombok.Value;
1313
import lombok.experimental.Accessors;
@@ -18,7 +18,7 @@ public class MongoCollectionOptionsApplier {
1818
private final Map<CacheKey, MongoCollection<BasicDBObject>> collectionCache;
1919

2020
public MongoCollectionOptionsApplier() {
21-
this.collectionCache = new HashMap<>();
21+
this.collectionCache = new ConcurrentHashMap<>();
2222
}
2323

2424
public MongoCollection<BasicDBObject> applyOptions(

0 commit comments

Comments
 (0)