chibenwa commented on code in PR #3053:
URL: https://github.com/apache/james-project/pull/3053#discussion_r3322020340


##########
mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAOV3.java:
##########
@@ -205,10 +213,28 @@ public long size() {
                 Mono<BlobId> headerFuture = 
Mono.from(blobStore.save(blobStore.getDefaultBucketName(), headerContent, 
SIZE_BASED));
                 Mono<BlobId> bodyFuture = 
Mono.from(blobStore.save(blobStore.getDefaultBucketName(), bodyByteSource, 
LOW_COST));
 
-                return headerFuture.zipWith(bodyFuture);
+                return headerFuture.zipWith(bodyFuture)
+                    .flatMap(pair -> saveRecovery(pair.getT1(), 
pair.getT2()).thenReturn(pair));
             });
     }
 
+    private Mono<Void> saveRecovery(BlobId headerId, BlobId bodyId) {
+        return switch (configuration.getBlobRecoveryMode()) {
+            case NONE -> Mono.empty();
+            case SYNCHRONOUS -> writeRecoveryBlob(headerId, bodyId);
+            case ASYNCHRONOUS -> Mono.fromRunnable(() ->
+                writeRecoveryBlob(headerId, bodyId)
+                    .subscribeOn(Schedulers.parallel())
+                    .subscribe(null, e -> LOGGER.error("Failed to save 
recovery blob for header={} body={}", headerId.asString(), bodyId.asString(), 
e)));

Review Comment:
   ```suggestion
                       .subscribe(ignored -> {}, e -> LOGGER.error("Failed to 
save recovery blob for header={} body={}", headerId.asString(), 
bodyId.asString(), e)));
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to