This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-4.14.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-4.14.x by this push:
new d1f46b355dfa CAMEL-22566: backlog tracer - Drain queue before adding
new trace event is more roboust (#19600)
d1f46b355dfa is described below
commit d1f46b355dfaa202bc6758c5d8331c837be5c209
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri Oct 17 18:44:15 2025 +0200
CAMEL-22566: backlog tracer - Drain queue before adding new trace event is
more roboust (#19600)
---
.../apache/camel/impl/debugger/BacklogTracer.java | 27 +++++++++++++++++-----
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/debugger/BacklogTracer.java
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/debugger/BacklogTracer.java
index 1c6c82a047ba..011df4b71cf7 100644
---
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/debugger/BacklogTracer.java
+++
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/debugger/BacklogTracer.java
@@ -135,15 +135,30 @@ public final class BacklogTracer extends ServiceSupport
implements org.apache.ca
return;
}
- // ensure there is space on the queue by polling until at least single
slot is free
- int drain = queue.size() - backlogSize + 1;
- if (drain > 0) {
- for (int i = 0; i < drain; i++) {
- queue.poll();
+ // pre-drain to make space
+ drain(false);
+
+ boolean added = false;
+ while (!added) {
+ try {
+ added = queue.add(event);
+ } catch (IllegalStateException e) {
+ drain(true);
}
}
+ }
- queue.add(event);
+ private void drain(boolean force) {
+ if (force) {
+ queue.poll();
+ } else {
+ int drain = queue.size() - backlogSize + 1;
+ if (drain > 0) {
+ for (int i = 0; i < drain; i++) {
+ queue.poll();
+ }
+ }
+ }
}
private boolean shouldTraceFilter(Exchange exchange) {