You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by rc...@apache.org on 2024/10/28 04:26:36 UTC
(james-project) 01/01: JAMES-2586 - Fixup InMemoryUploadRepository.deleteByUploadDateBefore
This is an automated email from the ASF dual-hosted git repository.
rcordier pushed a commit to branch postgresql
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 61b6018f2cd1eae40e3396388e05bb49f98394bf
Author: TungTV <vt...@linagora.com>
AuthorDate: Thu Oct 24 19:10:49 2024 +0700
JAMES-2586 - Fixup InMemoryUploadRepository.deleteByUploadDateBefore
- Fix java.util.ConcurrentModificationException
- Fix test InMemoryUploadRepositoryTest
---
.../org/apache/james/jmap/memory/upload/InMemoryUploadRepository.java | 3 ++-
.../apache/james/jmap/memory/upload/InMemoryUploadRepositoryTest.java | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/server/data/data-jmap/src/main/java/org/apache/james/jmap/memory/upload/InMemoryUploadRepository.java b/server/data/data-jmap/src/main/java/org/apache/james/jmap/memory/upload/InMemoryUploadRepository.java
index c3b98a95a3..9823214f98 100644
--- a/server/data/data-jmap/src/main/java/org/apache/james/jmap/memory/upload/InMemoryUploadRepository.java
+++ b/server/data/data-jmap/src/main/java/org/apache/james/jmap/memory/upload/InMemoryUploadRepository.java
@@ -25,6 +25,7 @@ import java.time.Clock;
import java.time.Duration;
import java.time.Instant;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import jakarta.inject.Inject;
@@ -113,7 +114,7 @@ public class InMemoryUploadRepository implements UploadRepository {
@Override
public Publisher<Void> deleteByUploadDateBefore(Duration expireDuration) {
Instant expirationTime = clock.instant().minus(expireDuration);
- return Flux.fromIterable(uploadStore.values())
+ return Flux.fromIterable(List.copyOf(uploadStore.values()))
.filter(pair -> pair.right.uploadDate().isBefore(expirationTime))
.flatMap(pair -> Mono.from(blobStore.delete(bucketName, pair.right.blobId()))
.then(Mono.fromRunnable(() -> uploadStore.remove(pair.right.uploadId()))))
diff --git a/server/data/data-jmap/src/test/java/org/apache/james/jmap/memory/upload/InMemoryUploadRepositoryTest.java b/server/data/data-jmap/src/test/java/org/apache/james/jmap/memory/upload/InMemoryUploadRepositoryTest.java
index 500d1ef823..d1f37e01ce 100644
--- a/server/data/data-jmap/src/test/java/org/apache/james/jmap/memory/upload/InMemoryUploadRepositoryTest.java
+++ b/server/data/data-jmap/src/test/java/org/apache/james/jmap/memory/upload/InMemoryUploadRepositoryTest.java
@@ -39,8 +39,8 @@ public class InMemoryUploadRepositoryTest implements UploadRepositoryContract {
@BeforeEach
void setUp() {
BlobStore blobStore = new DeDuplicationBlobStore(new MemoryBlobStoreDAO(), BucketName.DEFAULT, new PlainBlobId.Factory());
- testee = new InMemoryUploadRepository(blobStore, Clock.systemUTC());
clock = new UpdatableTickingClock(Clock.systemUTC().instant());
+ testee = new InMemoryUploadRepository(blobStore, clock);
}
@Override
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org