tolbertam commented on code in PR #2003:
URL:
https://github.com/apache/cassandra-java-driver/pull/2003#discussion_r1938351260
##########
core/src/main/java/com/datastax/oss/driver/internal/core/cql/CqlPrepareAsyncProcessor.java:
##########
@@ -53,23 +58,73 @@
public class CqlPrepareAsyncProcessor
implements RequestProcessor<PrepareRequest,
CompletionStage<PreparedStatement>> {
+ public class CacheEntry {
+
+ private CompletableFuture<PreparedStatement> result;
+ private Set<CompletableFuture<PreparedStatement>> futures;
+ private AtomicBoolean lock;
+
+ public CacheEntry() {
+
+ result = new CompletableFuture<>();
+ futures = Sets.newHashSet(result);
Review Comment:
One observation, `HashSet` is not thread safe, and futures get added to it
in the threads calling `prepare|Async` (main thread in tests) concurrently.
From what I can tell, `Set` is used here because in `process` we want to
ensure the future gets added before starting when creating the initial cache
entry, and then it's added after the entry is created to ensure it's accounted
for, right?
Can probably resolve this by using `ConcurrentHashMap` or
`Collections.synchronizedSet`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]