|
26 | 26 | import java.util.HashSet; |
27 | 27 | import java.util.List; |
28 | 28 | import java.util.Set; |
| 29 | +import java.util.concurrent.ExecutionException; |
29 | 30 | import java.util.concurrent.ExecutorService; |
30 | 31 | import java.util.concurrent.Executors; |
31 | 32 | import java.util.concurrent.Future; |
@@ -96,27 +97,22 @@ void testGetValueFromSetTooSmall() { |
96 | 97 | } |
97 | 98 |
|
98 | 99 | @Test |
99 | | - void testGetDynamicPropertyHandlerConcurrently() throws InterruptedException { |
| 100 | + void testGetDynamicPropertyHandlerConcurrently() throws InterruptedException, ExecutionException { |
100 | 101 | // This test is to ensure that the dynamic property handler can be accessed concurrently |
101 | 102 | // without throwing any exceptions. It does not assert any specific behavior, but rather |
102 | 103 | // ensures that no exceptions are thrown during concurrent access. |
103 | 104 | int nThreads = 200; // Number of threads to simulate concurrent access |
104 | 105 | List<Future<?>> futures = new ArrayList<>(); |
105 | 106 | ExecutorService threadPool = Executors.newFixedThreadPool(nThreads); |
106 | 107 | for (int i = 0; i < nThreads; i++) { |
107 | | - futures.add(threadPool.submit(() -> ValueUtils.getDynamicPropertyHandler(DummyHandler.class))); |
| 108 | + futures.add(threadPool.submit(() -> ValueUtils.getDynamicPropertyHandler(DummyHandler.class))); |
108 | 109 | } |
109 | 110 |
|
110 | 111 | threadPool.shutdown(); |
111 | 112 | threadPool.awaitTermination(1, TimeUnit.SECONDS); |
112 | 113 |
|
113 | 114 | for (Future<?> future : futures) { |
114 | | - try { |
115 | | - future.get(); // This will throw an exception if any thread encountered an issue |
116 | | - } catch (Exception e) { |
117 | | - // If an exception is thrown, the test fails |
118 | | - throw new AssertionError("Exception thrown during concurrent access", e); |
119 | | - } |
| 115 | + future.get(); // This will throw an exception if any thread encountered an issue |
120 | 116 | } |
121 | 117 | } |
122 | 118 |
|
|
0 commit comments