From c82e4563c2c0a3c97b0d02749e31e4b391a08762 Mon Sep 17 00:00:00 2001 From: Shichao Nie Date: Thu, 2 Nov 2023 19:01:31 +0800 Subject: [PATCH] fix(s3stream): fix potential NPE in compaction (#552) Signed-off-by: Shichao Nie --- .../java/com/automq/stream/s3/compact/CompactionManager.java | 5 +++-- .../java/com/automq/stream/s3/compact/CompactionUtils.java | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/s3stream/src/main/java/com/automq/stream/s3/compact/CompactionManager.java b/s3stream/src/main/java/com/automq/stream/s3/compact/CompactionManager.java index 1a6099358..eda57e243 100644 --- a/s3stream/src/main/java/com/automq/stream/s3/compact/CompactionManager.java +++ b/s3stream/src/main/java/com/automq/stream/s3/compact/CompactionManager.java @@ -233,8 +233,9 @@ private void logCompactionPlans(List compactionPlans, Set .mapToLong(CompactedObject::size) .sum()) .sum(); - logger.info("Compaction plans: expect to generate {} StreamObject, 1 WAL object with size {} in {} iterations, objects excluded: {}", - streamObjectNum, walObjectSize, compactionPlans.size(), excludedObjectIds); + int walObjectNum = walObjectSize > 0 ? 1 : 0; + logger.info("Compaction plans: expect to generate {} Stream Object, {} WAL object with size {} in {} iterations, objects excluded: {}", + streamObjectNum, walObjectNum, walObjectSize, compactionPlans.size(), excludedObjectIds); } public CompletableFuture forceSplitAll() { diff --git a/s3stream/src/main/java/com/automq/stream/s3/compact/CompactionUtils.java b/s3stream/src/main/java/com/automq/stream/s3/compact/CompactionUtils.java index 8c04c096b..bb3b544b9 100644 --- a/s3stream/src/main/java/com/automq/stream/s3/compact/CompactionUtils.java +++ b/s3stream/src/main/java/com/automq/stream/s3/compact/CompactionUtils.java @@ -52,7 +52,9 @@ public static List buildObjectStreamRange(List