From 8fb5acb0ce0db9297ac2531d52de53a1d400b775 Mon Sep 17 00:00:00 2001 From: Andrei Isvoran Date: Thu, 11 Jul 2024 09:01:48 +0200 Subject: [PATCH] RED-9579 - Use TaskExecutor so the TenantAwareTaskDecorator will correctly set... --- .../server/storage/ReportStorageServiceAsyncWrapper.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/storage/ReportStorageServiceAsyncWrapper.java b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/storage/ReportStorageServiceAsyncWrapper.java index 05efea1..19419a7 100644 --- a/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/storage/ReportStorageServiceAsyncWrapper.java +++ b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/storage/ReportStorageServiceAsyncWrapper.java @@ -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 storeObjectAsync(String downloadId, byte[] data) { - return CompletableFuture.supplyAsync(() -> reportStorageService.storeObject(downloadId, data), ioExecutor); + + return CompletableFuture.supplyAsync(() -> reportStorageService.storeObject(downloadId, data), taskExecutor); } + }