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 0ec0fd43b4f camel-jbang: Route controller CLI command
0ec0fd43b4f is described below

commit 0ec0fd43b4fa60b66238fd6431aea87a605dfb4a
Author: Claus Ibsen <[email protected]>
AuthorDate: Sat Oct 15 23:11:41 2022 +0200

    camel-jbang: Route controller CLI command
---
 .../org/apache/camel/impl/console/RouteControllerConsole.java  | 10 ++++++++++
 .../dsl/jbang/core/commands/action/RouteControllerAction.java  |  7 +++++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git 
a/core/camel-console/src/main/java/org/apache/camel/impl/console/RouteControllerConsole.java
 
b/core/camel-console/src/main/java/org/apache/camel/impl/console/RouteControllerConsole.java
index 0a5fc83aad4..5b7bde5583f 100644
--- 
a/core/camel-console/src/main/java/org/apache/camel/impl/console/RouteControllerConsole.java
+++ 
b/core/camel-console/src/main/java/org/apache/camel/impl/console/RouteControllerConsole.java
@@ -137,6 +137,11 @@ public class RouteControllerConsole extends 
AbstractDevConsole {
         } else {
             Set<Route> routes = new 
TreeSet<>(Comparator.comparing(Route::getId));
             routes.addAll(rc.getControlledRoutes());
+            if (routes.isEmpty()) {
+                // default route controller does not control routes but let's 
then just grab
+                // routes from context, so we have that to show
+                routes.addAll(getCamelContext().getRoutes());
+            }
             sb.append(String.format("Total Routes: %d", routes.size()));
             sb.append("\nRoutes:\n");
             for (Route route : routes) {
@@ -240,6 +245,11 @@ public class RouteControllerConsole extends 
AbstractDevConsole {
         } else {
             Set<Route> routes = new 
TreeSet<>(Comparator.comparing(Route::getId));
             routes.addAll(rc.getControlledRoutes());
+            if (routes.isEmpty()) {
+                // default route controller does not control routes but let's 
then just grab
+                // routes from context, so we have that to show
+                routes.addAll(getCamelContext().getRoutes());
+            }
 
             root.put("controller", "DefaultRouteController");
             root.put("totalRoutes", routes.size());
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/RouteControllerAction.java
 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/RouteControllerAction.java
index 5e521cdcd33..5412738ce7e 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/RouteControllerAction.java
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/RouteControllerAction.java
@@ -263,8 +263,11 @@ public class RouteControllerAction extends 
ActionBaseCommand {
     }
 
     protected String getLast(Row r) {
-        if (!r.lastAttemptAgo.isEmpty()) {
-            return r.lastAttemptAgo + " (" + r.elapsed + ")";
+        if (r.lastAttemptAgo != null && !r.lastAttemptAgo.isEmpty()) {
+            String s = r.lastAttemptAgo;
+            if (r.elapsed != null && !r.elapsed.isEmpty()) {
+                s += " (" + r.elapsed + ")";
+            }
         }
         return "";
     }

Reply via email to