From 74cce87c70385a629d3eb929c2767aec503ff0db Mon Sep 17 00:00:00 2001 From: Jun Kang Date: Mon, 1 Apr 2024 23:54:49 +0900 Subject: [PATCH] fix: Thread local storage test change (#2884) * Updated the imports in code of the single table inheritance pattern for Spring Boot 3.x #2825 Change javax library to jakarta * add pom.xml * Updated the imports in code of the healthcheck pattern for SpringBoot 3.x Change javax library to jakarta and update maven dependency versions * change order of imports to pass Checkstyle violations * change import order to pass lexicographical order test * change import order to pass CustomImportOrder warning * Updated the maven imports of layers pattern for SpringBoot 3.2.4 * remove unused maven import * Updated the maven imports of api-gateway pattern for SpringBoot 3.2.4 #2822 * Flaky test in Thread Local Storage #2880 * Rollback testing changes * Flaky test in Thread Local Storage #2880 Create independent threadLocal to make values unsharable and unchangable by other thread * rollback branch conflict --- .../src/test/java/ThreadLocalTest.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/thread-local-storage/src/test/java/ThreadLocalTest.java b/thread-local-storage/src/test/java/ThreadLocalTest.java index 9a31e48a8..0de7f0514 100644 --- a/thread-local-storage/src/test/java/ThreadLocalTest.java +++ b/thread-local-storage/src/test/java/ThreadLocalTest.java @@ -57,15 +57,15 @@ public class ThreadLocalTest { int threadSize = 2; ExecutorService executor = Executors.newFixedThreadPool(threadSize); - WithoutThreadLocal threadLocal = new WithoutThreadLocal(initialValue); for (int i = 0; i < threadSize; i++) { - executor.submit(threadLocal); + //Create independent thread + WithoutThreadLocal threadLocal = new WithoutThreadLocal(initialValue); + executor.submit(threadLocal); } executor.awaitTermination(3, TimeUnit.SECONDS); - List lines = outContent.toString().lines().toList(); - //Matches only first thread, the second has changed by first thread value - Assertions.assertFalse(lines.stream() + + Assertions.assertTrue(lines.stream() .allMatch(line -> line.endsWith(String.valueOf(initialValue)))); }