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

commit 0ae100d3e4a5009325b97b72a3c4552b3ef83e56
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Mon May 13 16:21:29 2024 +0200

    CAMEL-20761: camel-jbang debug need to deal with message history from camel 
4.7 onwards include current node.
---
 .../camel/impl/engine/CamelInternalProcessor.java  |  5 -----
 .../apache/camel/impl/console/DebugDevConsole.java |  1 +
 .../ROOT/pages/camel-4x-upgrade-guide-4_7.adoc     |  8 +++++++
 .../camel/dsl/jbang/core/commands/Debug.java       | 26 ++++++++++++++++++----
 4 files changed, 31 insertions(+), 9 deletions(-)

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 29514649b3c..ea0bc711009 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
@@ -743,11 +743,6 @@ public class CamelInternalProcessor extends 
DelegateAsyncProcessor implements In
             }
         }
 
-        @Override
-        public boolean hasState() {
-            return true;
-        }
-
     }
 
     /**
diff --git 
a/core/camel-console/src/main/java/org/apache/camel/impl/console/DebugDevConsole.java
 
b/core/camel-console/src/main/java/org/apache/camel/impl/console/DebugDevConsole.java
index 4146bdd1b47..4e3dcfb774e 100644
--- 
a/core/camel-console/src/main/java/org/apache/camel/impl/console/DebugDevConsole.java
+++ 
b/core/camel-console/src/main/java/org/apache/camel/impl/console/DebugDevConsole.java
@@ -151,6 +151,7 @@ public class DebugDevConsole extends AbstractDevConsole {
 
         BacklogDebugger backlog = 
getCamelContext().hasService(BacklogDebugger.class);
         if (backlog != null) {
+            root.put("version", getCamelContext().getVersion());
             root.put("enabled", backlog.isEnabled());
             root.put("standby", backlog.isStandby());
             root.put("suspendedMode", backlog.isSuspendMode());
diff --git 
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_7.adoc 
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_7.adoc
index 59fecdd7a5d..19e9dd64d9a 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_7.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_7.adoc
@@ -59,6 +59,14 @@ To:
 </route>
 ----
 
+=== camel-debug
+
+The debugger (using `org.apache.camel.spi.BacklogDebugger`) used for tooling 
such as IDEA and Visual Studio, is fixed
+to work better out-of-the-box by just having `camel-debug` JAR or 
`camel-debug-starter` (for Spring Boot) on the classpath.
+
+An internal change is that the MBean operation 
`messageHistoryOnBreakpointAsXml` on `ManagedBacklogDebugger` now includes
+the current node as last message history, which was expected by IDEA tooling, 
to make it function again.
+
 === camel-spring-security
 
 The `camel-spring-security` component has been updated to improve readiness 
for Spring Security 7.x. Since Spring Security 5.8 the `AccessDecisionManager` 
interface and the related cooperating classes have been deprecated in favor of 
`AuthorizationManager` based patterns.
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Debug.java
 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Debug.java
index 702489f69e5..49367ed2fd2 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Debug.java
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Debug.java
@@ -34,6 +34,7 @@ import java.util.concurrent.atomic.AtomicLong;
 import org.apache.camel.dsl.jbang.core.commands.action.MessageTableHelper;
 import org.apache.camel.dsl.jbang.core.common.CamelCommandHelper;
 import org.apache.camel.dsl.jbang.core.common.CommandLineHelper;
+import org.apache.camel.dsl.jbang.core.common.VersionHelper;
 import org.apache.camel.main.KameletMain;
 import org.apache.camel.util.FileUtil;
 import org.apache.camel.util.IOHelper;
@@ -338,6 +339,7 @@ public class Debug extends Run {
 
             // only read if expecting new data
             long cnt = jo.getLongOrDefault("debugCounter", 0);
+            String version = jo.getString("version");
             if (cnt > debugCounter.get()) {
                 JsonArray arr = jo.getCollection("suspended");
                 if (arr != null) {
@@ -351,7 +353,7 @@ public class Debug extends Run {
                     for (Object o : arr) {
                         SuspendedRow row = new SuspendedRow();
                         row.pid = String.valueOf(pid);
-                        row.name = "TODO";//pid.name;
+                        row.version = version;
                         jo = (JsonObject) o;
                         row.uid = jo.getLong("uid");
                         row.first = jo.getBoolean("first");
@@ -551,6 +553,13 @@ public class Debug extends Run {
                 if (row.history.size() > (i - 2)) {
                     History h = row.history.get(i - 2);
 
+                    // from camel 4.7 onwards then message history include 
current line as well
+                    // so the history panel needs to output a bit different in 
this situation
+                    boolean top = false;
+                    if (row.version != null && VersionHelper.isGE(row.version, 
"4.7")) {
+                        top = h == row.history.get(row.history.size() - 1);
+                    }
+
                     String ids;
                     if (source) {
                         ids = locationAndLine(h.location, h.line);
@@ -575,12 +584,21 @@ public class Debug extends Run {
                     }
 
                     String fids = String.format("%-30.30s", ids);
-                    String msg = String.format("%s %10.10s %4d:  %s", fids, 
elapsed, h.line, c);
+                    String msg;
+                    if (top && !row.last) {
+                        msg = String.format("%10.10s %s %4d:   %s", "--->", 
fids, h.line, c);
+                    } else {
+                        msg = String.format("%10.10s %s %4d:   %s", elapsed, 
fids, h.line, c);
+                    }
                     int len = msg.length();
                     if (loggingColor) {
                         fids = String.format("%-30.30s", ids);
                         fids = Ansi.ansi().fgCyan().a(fids).reset().toString();
-                        msg = String.format("%s %10.10s %4d:   %s", fids, 
elapsed, h.line, c);
+                        if (top && !row.last) {
+                            msg = String.format("%10.10s %s %4d:   %s", 
"--->", fids, h.line, c);
+                        } else {
+                            msg = String.format("%10.10s %s %4d:   %s", 
elapsed, fids, h.line, c);
+                        }
                     }
 
                     p.history = msg;
@@ -782,7 +800,7 @@ public class Debug extends Run {
 
     private static class SuspendedRow {
         String pid;
-        String name;
+        String version;
         boolean first;
         boolean last;
         long uid;

Reply via email to