This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new e98fbbc46cf3 CAMEL-20997: camel-jaxb - stop DataFormatConcurrentTest
hanging when a conversion fails (#31078)
e98fbbc46cf3 is described below
commit e98fbbc46cf3be554c4b1cff00a1f27184231bc0
Author: dhairya05 <[email protected]>
AuthorDate: Mon Nov 30 14:03:19 2026 +0530
CAMEL-20997: camel-jaxb - stop DataFormatConcurrentTest hanging when a
conversion fails (#31078)
Both unmarshal(...) and marshal(...) dispatch 10000 sends to a 20-thread
pool
and then wait on the test thread with an unbounded latch.await().
The latch is only counted down by the last step of the route, so the count
reaches zero only if all 10100 conversions succeed. If one JAXB conversion
fails, that exchange never reaches the .process, the latch never completes
and
the test thread waits forever.
The failure is invisible rather than slow: the sends use pool.execute, not
submit, so the exception goes to the uncaught-exception handler with no
Future
holding it; the assertDoesNotThrow wrapper cannot help because the test
thread
is parked, not throwing; and with no per-test timeout the symptom is the
whole
job killed on the CI timeout, naming no test and no cause.
Both waits are now bounded, and the message reports how many of the 10100
messages arrived, which separates "a conversion failed" from "this machine
is
slow". The pool is also shut down in a finally -- it was leaking 20 threads
per
test method, which matters when a surefire fork is reused across classes.
Two minutes is generous on purpose and only elapses when the test is already
broken; the whole class takes 13s, and all five tests pass.
Co-Authored-By: Claude <[email protected]>
---
.../camel/example/DataFormatConcurrentTest.java | 52 ++++++++++++++--------
1 file changed, 34 insertions(+), 18 deletions(-)
diff --git
a/components/camel-jaxb/src/test/java/org/apache/camel/example/DataFormatConcurrentTest.java
b/components/camel-jaxb/src/test/java/org/apache/camel/example/DataFormatConcurrentTest.java
index d7ada1c36a39..b80defac89f4 100644
---
a/components/camel-jaxb/src/test/java/org/apache/camel/example/DataFormatConcurrentTest.java
+++
b/components/camel-jaxb/src/test/java/org/apache/camel/example/DataFormatConcurrentTest.java
@@ -21,6 +21,7 @@ import java.io.StringWriter;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.Marshaller;
@@ -36,6 +37,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class DataFormatConcurrentTest extends CamelTestSupport {
@@ -169,16 +171,23 @@ public class DataFormatConcurrentTest extends
CamelTestSupport {
final ByteArrayInputStream[] payloads = createPayloads(testCycleCount);
ExecutorService pool = Executors.newFixedThreadPool(20);
StopWatch watch = new StopWatch();
- for (int i = 0; i < payloads.length; i++) {
- final int finalI = i;
- pool.execute(new Runnable() {
- public void run() {
- template.sendBody(payloads[finalI]);
- }
- });
- }
+ try {
+ for (int i = 0; i < payloads.length; i++) {
+ final int finalI = i;
+ pool.execute(new Runnable() {
+ public void run() {
+ template.sendBody(payloads[finalI]);
+ }
+ });
+ }
- latch.await();
+ assertTrue(latch.await(2, TimeUnit.MINUTES),
+ "only " + (warmupCount + testCycleCount - latch.getCount())
+ + " of " +
(warmupCount + testCycleCount)
+ + " messages reached
the end of the route");
+ } finally {
+ pool.shutdownNow();
+ }
long duration = watch.taken();
LOG.info("Sending {} messages to {} took {} ms",
@@ -195,16 +204,23 @@ public class DataFormatConcurrentTest extends
CamelTestSupport {
final Foo[] payloads = createFoo(testCycleCount);
ExecutorService pool = Executors.newFixedThreadPool(20);
StopWatch watch = new StopWatch();
- for (int i = 0; i < payloads.length; i++) {
- final int finalI = i;
- pool.execute(new Runnable() {
- public void run() {
- template.sendBody(payloads[finalI]);
- }
- });
- }
+ try {
+ for (int i = 0; i < payloads.length; i++) {
+ final int finalI = i;
+ pool.execute(new Runnable() {
+ public void run() {
+ template.sendBody(payloads[finalI]);
+ }
+ });
+ }
- latch.await();
+ assertTrue(latch.await(2, TimeUnit.MINUTES),
+ "only " + (warmupCount + testCycleCount - latch.getCount())
+ + " of " +
(warmupCount + testCycleCount)
+ + " messages reached
the end of the route");
+ } finally {
+ pool.shutdownNow();
+ }
long duration = watch.taken();
LOG.info("Sending {} messages to {} took {} ms",