Skip to content

Commit 19d9c53

Browse files
committed
Bubble up the exception rather than wrapping it in the unit test
1 parent c0237e7 commit 19d9c53

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/test/java/org/apache/commons/jxpath/util/ValueUtilsTest.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import java.util.HashSet;
2727
import java.util.List;
2828
import java.util.Set;
29+
import java.util.concurrent.ExecutionException;
2930
import java.util.concurrent.ExecutorService;
3031
import java.util.concurrent.Executors;
3132
import java.util.concurrent.Future;
@@ -96,27 +97,22 @@ void testGetValueFromSetTooSmall() {
9697
}
9798

9899
@Test
99-
void testGetDynamicPropertyHandlerConcurrently() throws InterruptedException {
100+
void testGetDynamicPropertyHandlerConcurrently() throws InterruptedException, ExecutionException {
100101
// This test is to ensure that the dynamic property handler can be accessed concurrently
101102
// without throwing any exceptions. It does not assert any specific behavior, but rather
102103
// ensures that no exceptions are thrown during concurrent access.
103104
int nThreads = 200; // Number of threads to simulate concurrent access
104105
List<Future<?>> futures = new ArrayList<>();
105106
ExecutorService threadPool = Executors.newFixedThreadPool(nThreads);
106107
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)));
108109
}
109110

110111
threadPool.shutdown();
111112
threadPool.awaitTermination(1, TimeUnit.SECONDS);
112113

113114
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
120116
}
121117
}
122118

0 commit comments

Comments
 (0)