This is an automated email from the ASF dual-hosted git repository.
apupier 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 9bb5bb39acdb CAMEL-27426: Fix flaky
ReplyManagerStopCompletesRequestsTest in camel-jms and camel-sjms
9bb5bb39acdb is described below
commit 9bb5bb39acdb2aa658bbe824ca82770264fdc38f
Author: Aurélien Pupier <[email protected]>
AuthorDate: Mon Nov 23 09:24:16 2026 +0100
CAMEL-27426: Fix flaky ReplyManagerStopCompletesRequestsTest in camel-jms
and camel-sjms
rejectedTimeoutTaskRunsInTheCallingThread registered t1, t2 and t3 with the
same blockOnce runnable, so whichever exchange completed first blocked on
the
latch. The test relies on t3 being rejected by the executor, and a rejected
timeout task runs on the timeout checker thread (CorrelationTimeoutMap
.submitEviction). When t3 completed before the executor thread had started
t1,
the checker thread blocked on the latch, so it could not evict the remaining
entries, evicted never reached 3 and the await timed out after 10 seconds.
Only block when running on the executor thread (OnTimeoutAbort), so the
checker
thread is never blocked. Reproduced without the fix under CPU load (1
failure
in 8 runs, same ConditionTimeoutException as in the JIRA); no failure in 11
runs with the fix.
Co-authored-by: IBM Bob 2.2.1
---
.../component/jms/reply/ReplyManagerStopCompletesRequestsTest.java | 6 ++++--
.../component/sjms/reply/ReplyManagerStopCompletesRequestsTest.java | 6 ++++--
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git
a/components/camel-jms/src/test/java/org/apache/camel/component/jms/reply/ReplyManagerStopCompletesRequestsTest.java
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/reply/ReplyManagerStopCompletesRequestsTest.java
index aff053beb887..38fba3842ede 100644
---
a/components/camel-jms/src/test/java/org/apache/camel/component/jms/reply/ReplyManagerStopCompletesRequestsTest.java
+++
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/reply/ReplyManagerStopCompletesRequestsTest.java
@@ -224,11 +224,13 @@ class ReplyManagerStopCompletesRequestsTest {
evicted.incrementAndGet();
}
});
- // the first timeout task holds the only thread, the second fills the
queue, the third is rejected
+ // the first timeout task holds the only thread, the second fills the
queue, the third is rejected. Only the
+ // first task to run on the executor thread blocks: a task that runs
in the timeout checker thread (the
+ // rejected one) must not block, or the checker could not evict the
remaining entries
AtomicBoolean first = new AtomicBoolean();
CountDownLatch release = new CountDownLatch(1);
Runnable blockOnce = () -> {
- if (first.compareAndSet(false, true)) {
+ if (Thread.currentThread().getName().contains("OnTimeoutAbort") &&
first.compareAndSet(false, true)) {
awaitLatch(release);
}
};
diff --git
a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/reply/ReplyManagerStopCompletesRequestsTest.java
b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/reply/ReplyManagerStopCompletesRequestsTest.java
index 47167d244cc5..c215570ecc9d 100644
---
a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/reply/ReplyManagerStopCompletesRequestsTest.java
+++
b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/reply/ReplyManagerStopCompletesRequestsTest.java
@@ -224,11 +224,13 @@ class ReplyManagerStopCompletesRequestsTest {
evicted.incrementAndGet();
}
});
- // the first timeout task holds the only thread, the second fills the
queue, the third is rejected
+ // the first timeout task holds the only thread, the second fills the
queue, the third is rejected. Only the
+ // first task to run on the executor thread blocks: a task that runs
in the timeout checker thread (the
+ // rejected one) must not block, or the checker could not evict the
remaining entries
AtomicBoolean first = new AtomicBoolean();
CountDownLatch release = new CountDownLatch(1);
Runnable blockOnce = () -> {
- if (first.compareAndSet(false, true)) {
+ if (Thread.currentThread().getName().contains("OnTimeoutAbort") &&
first.compareAndSet(false, true)) {
awaitLatch(release);
}
};