From 2d29e035a2950990fd623d049e8e04e2f0781059 Mon Sep 17 00:00:00 2001 From: Oleg Kopysov Date: Wed, 21 Feb 2024 14:38:48 +0200 Subject: [PATCH] fix: Clear the queue before adding new elements Signed-off-by: Oleg Kopysov --- src/main/java/com/lpvs/LicensePreValidationSystem.java | 2 +- src/main/java/com/lpvs/service/LPVSQueueService.java | 1 + src/test/java/com/lpvs/LicensePreValidationSystemTest.java | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/lpvs/LicensePreValidationSystem.java b/src/main/java/com/lpvs/LicensePreValidationSystem.java index 5f4a9819..3acc2bfa 100644 --- a/src/main/java/com/lpvs/LicensePreValidationSystem.java +++ b/src/main/java/com/lpvs/LicensePreValidationSystem.java @@ -71,7 +71,7 @@ public static void main(String[] args) { public TaskExecutor getAsyncExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setCorePoolSize(corePoolSize); - executor.setThreadNamePrefix("LPVS-ASYNC::"); + executor.setThreadNamePrefix("LPVS::"); return executor; } } diff --git a/src/main/java/com/lpvs/service/LPVSQueueService.java b/src/main/java/com/lpvs/service/LPVSQueueService.java index f76780bd..3664df78 100644 --- a/src/main/java/com/lpvs/service/LPVSQueueService.java +++ b/src/main/java/com/lpvs/service/LPVSQueueService.java @@ -147,6 +147,7 @@ public BlockingDeque getQueue() { * @throws InterruptedException If interrupted while processing the queue. */ public void checkForQueue() throws InterruptedException { + QUEUE.clear(); log.debug("Checking for previous queue"); List webhookConfigList = queueRepository.getQueueList(); for (LPVSQueue webhook : webhookConfigList) { diff --git a/src/test/java/com/lpvs/LicensePreValidationSystemTest.java b/src/test/java/com/lpvs/LicensePreValidationSystemTest.java index 081d494f..de7d4f89 100644 --- a/src/test/java/com/lpvs/LicensePreValidationSystemTest.java +++ b/src/test/java/com/lpvs/LicensePreValidationSystemTest.java @@ -37,7 +37,7 @@ public void testGetAsyncExecutor() { assertEquals(executor, mocked_constructed_executor); verify(mocked_constructed_executor, times(1)).setCorePoolSize(testNumCores); - verify(mocked_constructed_executor, times(1)).setThreadNamePrefix("LPVS-ASYNC::"); + verify(mocked_constructed_executor, times(1)).setThreadNamePrefix("LPVS::"); verifyNoMoreInteractions(mocked_constructed_executor); } }