From 5909bd6f68775c8665e1d9889d6ad54915e5f5fe Mon Sep 17 00:00:00 2001 From: SamuelQuetin Date: Wed, 30 Oct 2024 14:16:10 +0100 Subject: [PATCH] Fix executor pas reset --- src/main/java/fr/abes/kbart2kafka/service/FileService.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/fr/abes/kbart2kafka/service/FileService.java b/src/main/java/fr/abes/kbart2kafka/service/FileService.java index 6b60d18..0f5bb32 100644 --- a/src/main/java/fr/abes/kbart2kafka/service/FileService.java +++ b/src/main/java/fr/abes/kbart2kafka/service/FileService.java @@ -7,14 +7,12 @@ import fr.abes.kbart2kafka.exception.IllegalFileFormatException; import fr.abes.kbart2kafka.utils.PUBLICATION_TYPE; import fr.abes.kbart2kafka.utils.Utils; -import jakarta.annotation.PostConstruct; import lombok.extern.slf4j.Slf4j; import org.apache.kafka.clients.producer.ProducerRecord; import org.apache.logging.log4j.ThreadContext; import org.springframework.beans.factory.annotation.Value; import org.springframework.kafka.core.KafkaTemplate; import org.springframework.stereotype.Service; -import org.yaml.snakeyaml.util.EnumUtils; import java.io.BufferedReader; import java.io.File; @@ -49,7 +47,7 @@ public FileService(KafkaTemplate kafkaTemplate, ObjectMapper map this.lastThreadUsed = new AtomicInteger(0); } - @PostConstruct +// @PostConstruct void initExecutor() { executor = Executors.newFixedThreadPool(nbThread); } @@ -60,6 +58,7 @@ public void loadFile(File fichier) throws IllegalFileFormatException, IOExceptio } private void executeMultiThread(File fichier) throws IllegalFileFormatException { + initExecutor(); try (BufferedReader buff = new BufferedReader(new FileReader(fichier))) { List fileContent = buff.lines().toList(); List kbartsToSend = new ArrayList<>();