diff --git a/distribution/conf/log4j2.xml b/distribution/conf/log4j2.xml index 331c4cd62..8543ad50f 100644 --- a/distribution/conf/log4j2.xml +++ b/distribution/conf/log4j2.xml @@ -45,6 +45,9 @@ + + + diff --git a/metadata/src/main/java/com/automq/rocketmq/metadata/s3/DefaultS3MetadataService.java b/metadata/src/main/java/com/automq/rocketmq/metadata/s3/DefaultS3MetadataService.java index b80e8a14e..fd1cf3aaf 100644 --- a/metadata/src/main/java/com/automq/rocketmq/metadata/s3/DefaultS3MetadataService.java +++ b/metadata/src/main/java/com/automq/rocketmq/metadata/s3/DefaultS3MetadataService.java @@ -239,11 +239,7 @@ public CompletableFuture commitWalObject(S3WALObject walObject, object.setEndOffset(s3StreamObject.getEndOffset()); object.setObjectSize(s3StreamObject.getObjectSize()); s3StreamObjectMapper.commit(object); - if (toCache.containsKey(object.getStreamId())) { - toCache.get(object.getStreamId()).add(object); - } else { - toCache.put(object.getStreamId(), List.of(object)); - } + toCache.computeIfAbsent(object.getStreamId(), streamId -> new ArrayList<>()).add(object); }); } @@ -330,8 +326,7 @@ public CompletableFuture commitStreamObject(apache.rocketmq.controller.v1. .min(Long::compareTo).get(); } - List - toCache = new ArrayList<>(); + List toCache = new ArrayList<>(); // create a new S3StreamObject to replace committed ones if (streamObject.getObjectId() != S3Constants.NOOP_OBJECT_ID) {