From ee043382467b2fe5e194296ffa4500279066155b Mon Sep 17 00:00:00 2001 From: Shichao Nie Date: Wed, 24 Jul 2024 15:51:57 +0800 Subject: [PATCH] fix(s3stream): fix index out of bound exception Signed-off-by: Shichao Nie --- .../com/automq/stream/s3/compact/CompactionManager.java | 8 ++++++++ 1 file changed, 8 insertions(+) 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 6ac2b9384b..fc924ea265 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 @@ -137,6 +137,14 @@ public void start() { scheduleNextCompaction((long) this.compactionInterval * 60 * 1000); this.utilityScheduledExecutor.scheduleAtFixedRate(() -> this.objectManager.getServerObjects().whenComplete((data, ex) -> { + if (ex != null) { + logger.error("Error while getting server objects ", ex); + return; + } + if (data == null || data.isEmpty()) { + this.compactionDelayTime = 0; + return; + } data.sort(Comparator.comparingLong(S3ObjectMetadata::committedTimestamp)); this.compactionDelayTime = System.currentTimeMillis() - data.get(0).committedTimestamp(); }).join(), 1, 1, TimeUnit.MINUTES);