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 6947f5a8fcf7 CAMEL-25435: camel-core - backlog tracer and debugger end
a cut node label with an ellipsis (#27533)
6947f5a8fcf7 is described below
commit 6947f5a8fcf75720713f365c99dc85e9f42d0995
Author: Claus Ibsen <[email protected]>
AuthorDate: Thu Oct 8 08:32:48 2026 +0200
CAMEL-25435: camel-core - backlog tracer and debugger end a cut node label
with an ellipsis (#27533)
* CAMEL-25435: camel-core - backlog tracer and debugger end a cut node
label with an ellipsis
The backlog tracer and debugger cut the label of a node to 50 characters
without saying so, so a tool showing it took a cut label for the whole one
(unmarshal[org.apache.camel.model.dataformat.JsonDa). A cut label now ends
with "...".
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01STT6whBgK1AqsSsUKrnE8m
* CAMEL-25435: name the limitLength argument a suffix, test the debugger
label
Review follow-up: the third argument of StringHelper.limitLength is
appended, so it is a suffix, not a prefix. A test covers the label at a
breakpoint of the backlog debugger, and the expected length says how it
is made.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01STT6whBgK1AqsSsUKrnE8m
---------
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
---
.../apache/camel/impl/debugger/BacklogTracer.java | 3 +-
.../impl/debugger/DefaultBacklogDebugger.java | 4 +-
.../camel/impl/engine/CamelInternalProcessor.java | 2 +-
.../processor/BacklogTracerLongLabelTest.java | 87 ++++++++++++++++++++++
.../java/org/apache/camel/util/StringHelper.java | 11 +--
5 files changed, 98 insertions(+), 9 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 6582324dae1b..a83cac53c0cf 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
@@ -194,7 +194,8 @@ public class BacklogTracer extends ServiceSupport
implements org.apache.camel.sp
String toNode = node.getId();
String toNodeParentId = node.getParentId();
String toNodeShortName = node.getShortName();
- String toNodeLabel = StringHelper.limitLength(node.getLabel(), 50);
+ // a cut label ends with an ellipsis, so a tool showing it does not
take it for the whole label
+ String toNodeLabel = StringHelper.limitLength(node.getLabel(), 50,
"...");
String exchangeId = exchange.getExchangeId();
String correlationExchangeId =
exchange.getProperty(ExchangePropertyKey.CORRELATION_ID, String.class);
String breadcrumbId =
exchange.getIn().getHeader(Exchange.BREADCRUMB_ID, String.class);
diff --git
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/debugger/DefaultBacklogDebugger.java
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/debugger/DefaultBacklogDebugger.java
index 0418803b1157..7b2e8005a31a 100644
---
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/debugger/DefaultBacklogDebugger.java
+++
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/debugger/DefaultBacklogDebugger.java
@@ -953,7 +953,7 @@ public final class DefaultBacklogDebugger extends
ServiceSupport implements Back
String toNodeParentId = definition.getParentId();
String toNodeShortName = definition.getShortName();
// avoid label is too large
- String toNodeLabel =
StringHelper.limitLength(definition.getLabel(), 50);
+ String toNodeLabel =
StringHelper.limitLength(definition.getLabel(), 50, "...");
String fromRouteId = exchange.getFromRouteId();
String routeId = CamelContextHelper.getRouteId(definition);
String exchangeId = exchange.getExchangeId();
@@ -1045,7 +1045,7 @@ public final class DefaultBacklogDebugger extends
ServiceSupport implements Back
String toNodeParentId = definition.getParentId();
String toNodeShortName = definition.getShortName();
// avoid label is too large
- String toNodeLabel =
StringHelper.limitLength(definition.getLabel(), 50);
+ String toNodeLabel =
StringHelper.limitLength(definition.getLabel(), 50, "...");
String fromRouteId = exchange.getFromRouteId();
String routeId = CamelContextHelper.getRouteId(definition);
String exchangeId = exchange.getExchangeId();
diff --git
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/CamelInternalProcessor.java
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/CamelInternalProcessor.java
index ae37ef23e671..bbaa2efb053b 100644
---
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/CamelInternalProcessor.java
+++
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/CamelInternalProcessor.java
@@ -963,7 +963,7 @@ public class CamelInternalProcessor extends
DelegateAsyncProcessor implements In
toNodeParentWhenLabel = mn.getLabel();
}
}
- String toNodeLabel =
StringHelper.limitLength(processorDefinition.getLabel(), 50);
+ String toNodeLabel =
StringHelper.limitLength(processorDefinition.getLabel(), 50, "...");
String exchangeId = exchange.getExchangeId();
String correlationExchangeId =
exchange.getProperty(ExchangePropertyKey.CORRELATION_ID, String.class);
String breadcrumbId =
exchange.getIn().getHeader(Exchange.BREADCRUMB_ID, String.class);
diff --git
a/core/camel-core/src/test/java/org/apache/camel/processor/BacklogTracerLongLabelTest.java
b/core/camel-core/src/test/java/org/apache/camel/processor/BacklogTracerLongLabelTest.java
new file mode 100644
index 000000000000..f0e9777b42f2
--- /dev/null
+++
b/core/camel-core/src/test/java/org/apache/camel/processor/BacklogTracerLongLabelTest.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.processor;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.spi.BacklogDebugger;
+import org.apache.camel.spi.BacklogTracer;
+import org.apache.camel.spi.BacklogTracerEventMessage;
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * A node label too long for the trace is cut with an ellipsis, so a tool
showing it does not take it for the whole
+ * label.
+ */
+class BacklogTracerLongLabelTest extends ContextTestSupport {
+
+ @Test
+ void aLongLabelEndsWithAnEllipsis() {
+ BacklogTracer tracer =
context.getCamelContextExtension().getContextPlugin(BacklogTracer.class);
+ tracer.setEnabled(true);
+
+ template.sendBody("direct:start", "Hello");
+
+ // a dump takes the messages out of the tracer
+ List<BacklogTracerEventMessage> events =
tracer.dumpAllTracedMessages();
+ BacklogTracerEventMessage setBody = events.stream()
+ .filter(e ->
"setBody".equals(e.getToNodeShortName())).findFirst().orElseThrow();
+ assertThat(setBody.getToNodeLabel()).hasSize(50 +
"...".length()).endsWith("...");
+ BacklogTracerEventMessage log = events.stream()
+ .filter(e ->
"log".equals(e.getToNodeShortName())).findFirst().orElseThrow();
+ assertThat(log.getToNodeLabel()).doesNotEndWith("...");
+ }
+
+ @Test
+ void aLongLabelAtABreakpointEndsWithAnEllipsis() throws Exception {
+ BacklogDebugger debugger = context.hasService(BacklogDebugger.class);
+ debugger.enableDebugger();
+ debugger.addBreakpoint("long");
+ try {
+ template.asyncSendBody("direct:start", "Hello");
+ Awaitility.await().atMost(5, TimeUnit.SECONDS)
+ .until(() ->
debugger.getSuspendedBreakpointNodeIds().contains("long"));
+
+ BacklogTracerEventMessage suspended =
debugger.getSuspendedBreakpointMessage("long");
+ assertThat(suspended.getToNodeLabel()).hasSize(50 +
"...".length()).endsWith("...");
+ } finally {
+ debugger.resumeAll();
+ debugger.disableDebugger();
+ }
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ context.setBacklogTracing(true);
+ context.setDebugging(true);
+
+ from("direct:start")
+ .setBody(simple("${body} and a rather long text that
makes the label longer than fifty")).id("long")
+ .log("short");
+ }
+ };
+ }
+}
diff --git
a/core/camel-util/src/main/java/org/apache/camel/util/StringHelper.java
b/core/camel-util/src/main/java/org/apache/camel/util/StringHelper.java
index 4a19a6f84f92..08b4cb7f82a9 100644
--- a/core/camel-util/src/main/java/org/apache/camel/util/StringHelper.java
+++ b/core/camel-util/src/main/java/org/apache/camel/util/StringHelper.java
@@ -120,10 +120,11 @@ public final class StringHelper {
*
* @param s the string
* @param maxLength the maximum length of the returned string
- * @param prefix prefix to append if the string was limited
- * @return s if the length of s is less than maxLength or the
first maxLength characters of s
+ * @param suffix suffix to append if the string was limited, such as
an ellipsis
+ * @return s if the length of s is less than maxLength or the
first maxLength characters of s followed by
+ * the suffix
*/
- public static String limitLength(String s, int maxLength, String prefix) {
+ public static String limitLength(String s, int maxLength, String suffix) {
if (ObjectHelper.isEmpty(s)) {
return s;
}
@@ -131,8 +132,8 @@ public final class StringHelper {
return s;
}
s = s.substring(0, maxLength);
- if (prefix != null) {
- s = s + prefix;
+ if (suffix != null) {
+ s = s + suffix;
}
return s;
}