From d1cdb6b75b8cfcb376b4f037e8926b828d8dae9e Mon Sep 17 00:00:00 2001 From: Shichao Nie Date: Wed, 13 Dec 2023 18:44:32 +0800 Subject: [PATCH] =?UTF-8?q?fix(s3stream):=20remove=20future=20before=20com?= =?UTF-8?q?plete=20it=20to=20prevent=20infinite=20r=E2=80=A6=20(#830)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Shichao Nie --- .../java/com/automq/stream/s3/cache/StreamReader.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/s3stream/src/main/java/com/automq/stream/s3/cache/StreamReader.java b/s3stream/src/main/java/com/automq/stream/s3/cache/StreamReader.java index 013868f65..83114090f 100644 --- a/s3stream/src/main/java/com/automq/stream/s3/cache/StreamReader.java +++ b/s3stream/src/main/java/com/automq/stream/s3/cache/StreamReader.java @@ -422,14 +422,14 @@ CompletableFuture getDataBlockIndices(long streamId, long endOffset, ReadC } private void completeInflightTask(DefaultS3BlockCache.ReadAheadTaskKey key, Throwable ex) { - inflightReadAheadTaskMap.computeIfPresent(key, (k, v) -> { + CompletableFuture cf = inflightReadAheadTaskMap.remove(key); + if (cf != null) { if (ex != null) { - v.completeExceptionally(ex); + cf.completeExceptionally(ex); } else { - v.complete(null); + cf.complete(null); } - return null; - }); + } } private List> collectStreamDataBlocksToRead(ReadContext context) {