Merge branch 'RED-9579-executor' into 'release/4.73.x'

RED-9579 - Use TaskExecutor so the TenantAwareTaskDecorator will correctly set...

See merge request redactmanager/redaction-report-service!84
This commit is contained in:
Andrei Isvoran 2024-07-11 09:01:49 +02:00
commit 33e1198440

View File

@ -1,9 +1,8 @@
package com.iqser.red.service.redaction.report.v1.server.storage;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import org.springframework.core.task.TaskExecutor;
import org.springframework.stereotype.Service;
import lombok.RequiredArgsConstructor;
@ -16,10 +15,12 @@ import lombok.RequiredArgsConstructor;
public class ReportStorageServiceAsyncWrapper {
private final ReportStorageService reportStorageService;
private final Executor ioExecutor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
private final TaskExecutor taskExecutor;
public CompletableFuture<String> storeObjectAsync(String downloadId, byte[] data) {
return CompletableFuture.supplyAsync(() -> reportStorageService.storeObject(downloadId, data), ioExecutor);
return CompletableFuture.supplyAsync(() -> reportStorageService.storeObject(downloadId, data), taskExecutor);
}
}