tolbertam commented on code in PR #2003:
URL: 
https://github.com/apache/cassandra-java-driver/pull/2003#discussion_r1938345833


##########
core/src/main/java/com/datastax/oss/driver/internal/core/cql/CqlPrepareAsyncProcessor.java:
##########
@@ -141,25 +195,23 @@ public CompletionStage<PreparedStatement> process(
       String sessionLogPrefix) {
 
     try {
-      CompletableFuture<PreparedStatement> result = 
cache.getIfPresent(request);
-      if (result == null) {
-        CompletableFuture<PreparedStatement> mine = new CompletableFuture<>();
-        result = cache.get(request, () -> mine);
-        if (result == mine) {
-          new CqlPrepareHandler(request, session, context, sessionLogPrefix)
-              .handle()
-              .whenComplete(
-                  (preparedStatement, error) -> {
-                    if (error != null) {
-                      mine.completeExceptionally(error);
-                      cache.invalidate(request); // Make sure failure isn't 
cached indefinitely
-                    } else {
-                      mine.complete(preparedStatement);
-                    }
-                  });
-        }
-      }
-      return result;
+      CompletableFuture<PreparedStatement> rv = new CompletableFuture<>();
+      CacheEntry entry =
+          cache.get(
+              request,
+              () -> {
+                CacheEntry newEntry = new CacheEntry();
+                newEntry.addFuture(rv);
+                newEntry.tryStart(request, session, context, sessionLogPrefix);
+                return newEntry;
+              });
+
+      // We don't know whether we're dealing with a newly-created entry or one 
that was
+      // already cached so try the future insert again.  We wind up duoing an 
extra hash op

Review Comment:
   duoing -> doing



-- 
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]

Reply via email to