mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-14 06:58:54 +00:00
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
This commit is contained in:
@@ -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<String> 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))));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user