Skip to content

Commit 74cce87

Browse files
authored
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
1 parent 9258cc8 commit 74cce87

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Diff for: thread-local-storage/src/test/java/ThreadLocalTest.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ public void withoutThreadLocal() throws InterruptedException {
5757
int threadSize = 2;
5858
ExecutorService executor = Executors.newFixedThreadPool(threadSize);
5959

60-
WithoutThreadLocal threadLocal = new WithoutThreadLocal(initialValue);
6160
for (int i = 0; i < threadSize; i++) {
62-
executor.submit(threadLocal);
61+
//Create independent thread
62+
WithoutThreadLocal threadLocal = new WithoutThreadLocal(initialValue);
63+
executor.submit(threadLocal);
6364
}
6465
executor.awaitTermination(3, TimeUnit.SECONDS);
65-
6666
List<String> lines = outContent.toString().lines().toList();
67-
//Matches only first thread, the second has changed by first thread value
68-
Assertions.assertFalse(lines.stream()
67+
68+
Assertions.assertTrue(lines.stream()
6969
.allMatch(line -> line.endsWith(String.valueOf(initialValue))));
7070
}
7171

0 commit comments

Comments
 (0)