Skip to content

Commit 7f6d964

Browse files
committed
Prevent reusing cached cancelled requests
There was a critical issue in the driver that may occur when the external code cancels a request, indeed the CompletableFuture will then always throw a CancellationException. This could occur for example when used in a reactive context with a Mono.zip failed.
1 parent 2bf500e commit 7f6d964

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

core/src/main/java/com/datastax/oss/driver/internal/core/cql/CqlPrepareAsyncProcessor.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,10 @@ public CompletionStage<PreparedStatement> process(
142142

143143
try {
144144
CompletableFuture<PreparedStatement> result = cache.getIfPresent(request);
145-
if (result == null) {
145+
if (result == null || result.isCancelled()) {
146+
if (result.isCancelled()) {
147+
cache.invalidate(request);
148+
}
146149
CompletableFuture<PreparedStatement> mine = new CompletableFuture<>();
147150
result = cache.get(request, () -> mine);
148151
if (result == mine) {

0 commit comments

Comments
 (0)