You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2022/01/06 11:14:18 UTC

[camel] branch main updated (40595b4 -> 661c36e)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from 40595b4  Regen for commit 0ca042e3de2246802b8cfb1df38617b6ab1ff1c8 (#6664)
     new f712ed9  CAMEL-17417: camel-core - Route stack trace to include source file:line
     new 661c36e  CAMEL-17417: camel-core - Route stack trace to include source file:line

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/camel/support/MessageHelper.java    | 53 +++++++++++++---------
 .../ROOT/pages/camel-3x-upgrade-guide-3_15.adoc    | 20 ++++----
 2 files changed, 42 insertions(+), 31 deletions(-)

[camel] 02/02: CAMEL-17417: camel-core - Route stack trace to include source file:line

Posted by da...@apache.org.
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 661c36e0e45c1bde2b638cb199b230e0f77f96a5
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Jan 6 12:13:42 2022 +0100

    CAMEL-17417: camel-core - Route stack trace to include source file:line
---
 .../org/apache/camel/support/MessageHelper.java    | 42 +++++++++++++---------
 1 file changed, 25 insertions(+), 17 deletions(-)

diff --git a/core/camel-support/src/main/java/org/apache/camel/support/MessageHelper.java b/core/camel-support/src/main/java/org/apache/camel/support/MessageHelper.java
index 7959313..12eefaf 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/MessageHelper.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/MessageHelper.java
@@ -556,22 +556,6 @@ public final class MessageHelper {
     @SuppressWarnings("unchecked")
     private static String doDumpMessageHistoryStacktrace(
             Exchange exchange, ExchangeFormatter exchangeFormatter, boolean logStackTrace) {
-        List<MessageHistory> list = exchange.getProperty(ExchangePropertyKey.MESSAGE_HISTORY, List.class);
-        boolean enabled = list != null;
-
-        StringBuilder sb = new StringBuilder();
-        sb.append("\n");
-        sb.append("Message History");
-        if (!enabled) {
-            sb.append(" (complete message history is disabled)");
-        }
-        sb.append("\n");
-        sb.append(
-                "---------------------------------------------------------------------------------------------------------------------------------------\n");
-        String goMessageHistoryHeader = exchange.getContext().getGlobalOption(Exchange.MESSAGE_HISTORY_HEADER_FORMAT);
-        sb.append(String.format(goMessageHistoryHeader == null ? MESSAGE_HISTORY_HEADER : goMessageHistoryHeader,
-                "Source", "ID", "Processor", "Elapsed (ms)"));
-        sb.append("\n");
 
         // add incoming origin of message on the top
         String routeId = exchange.getFromRouteId();
@@ -588,6 +572,28 @@ public final class MessageHelper {
         }
         long elapsed = new StopWatch(exchange.getCreated()).taken();
 
+        List<MessageHistory> list = exchange.getProperty(ExchangePropertyKey.MESSAGE_HISTORY, List.class);
+        boolean enabled = list != null;
+        boolean source = !loc.isEmpty();
+
+        StringBuilder sb = new StringBuilder();
+        sb.append("\n");
+        sb.append("Message History");
+        if (!source && !enabled) {
+            sb.append(" (source location and message history is disabled)");
+        } else if (!source) {
+            sb.append(" (source location is disabled)");
+        } else if (!enabled) {
+            sb.append(" (complete message history is disabled)");
+        }
+        sb.append("\n");
+        sb.append(
+                "---------------------------------------------------------------------------------------------------------------------------------------\n");
+        String goMessageHistoryHeader = exchange.getContext().getGlobalOption(Exchange.MESSAGE_HISTORY_HEADER_FORMAT);
+        sb.append(String.format(goMessageHistoryHeader == null ? MESSAGE_HISTORY_HEADER : goMessageHistoryHeader,
+                "Source", "ID", "Processor", "Elapsed (ms)"));
+        sb.append("\n");
+
         String goMessageHistoryOutput = exchange.getContext().getGlobalOption(Exchange.MESSAGE_HISTORY_OUTPUT_FORMAT);
         goMessageHistoryOutput = goMessageHistoryOutput == null ? MESSAGE_HISTORY_OUTPUT : goMessageHistoryOutput;
         sb.append(String.format(goMessageHistoryOutput, loc, routeId + "/" + id, label, elapsed));
@@ -598,8 +604,10 @@ public final class MessageHelper {
             // instead
             id = exchange.adapt(ExtendedExchange.class).getHistoryNodeId();
             if (id != null) {
-                // compute route id
                 loc = exchange.adapt(ExtendedExchange.class).getHistoryNodeSource();
+                if (loc == null) {
+                    loc = "";
+                }
                 String rid = ExchangeHelper.getAtRouteId(exchange);
                 if (rid != null) {
                     routeId = rid;

[camel] 01/02: CAMEL-17417: camel-core - Route stack trace to include source file:line

Posted by da...@apache.org.
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 f712ed9aa77d121d623e173f8629808f36d7b110
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Jan 6 12:06:23 2022 +0100

    CAMEL-17417: camel-core - Route stack trace to include source file:line
---
 .../java/org/apache/camel/support/MessageHelper.java | 19 +++++++++++--------
 .../ROOT/pages/camel-3x-upgrade-guide-3_15.adoc      | 20 ++++++++++----------
 2 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/core/camel-support/src/main/java/org/apache/camel/support/MessageHelper.java b/core/camel-support/src/main/java/org/apache/camel/support/MessageHelper.java
index fd98a0f..7959313 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/MessageHelper.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/MessageHelper.java
@@ -49,8 +49,8 @@ import org.slf4j.Logger;
 @EagerClassloaded
 public final class MessageHelper {
 
-    private static final String MESSAGE_HISTORY_HEADER = "%-30s %-20s %-20s %-50s %-12s";
-    private static final String MESSAGE_HISTORY_OUTPUT = "%-30.30s %-20.20s %-20.20s %-50.50s %12.12s";
+    private static final String MESSAGE_HISTORY_HEADER = "%-40s %-30s %-50s %-12s";
+    private static final String MESSAGE_HISTORY_OUTPUT = "%-40.40s %-30.30s %-50.50s %12.12s";
 
     /**
      * Utility classes should not have a public constructor.
@@ -570,13 +570,16 @@ public final class MessageHelper {
                 "---------------------------------------------------------------------------------------------------------------------------------------\n");
         String goMessageHistoryHeader = exchange.getContext().getGlobalOption(Exchange.MESSAGE_HISTORY_HEADER_FORMAT);
         sb.append(String.format(goMessageHistoryHeader == null ? MESSAGE_HISTORY_HEADER : goMessageHistoryHeader,
-                "Location", "RouteId", "ProcessorId", "Processor", "Elapsed (ms)"));
+                "Source", "ID", "Processor", "Elapsed (ms)"));
         sb.append("\n");
 
         // add incoming origin of message on the top
         String routeId = exchange.getFromRouteId();
         Route route = exchange.getContext().getRoute(routeId);
-        String loc = route != null ? route.getSourceLocation() : "";
+        String loc = route != null ? route.getSourceLocation() : null;
+        if (loc == null) {
+            loc = "";
+        }
         String id = routeId;
         String label = "";
         if (exchange.getFromEndpoint() != null) {
@@ -587,7 +590,7 @@ public final class MessageHelper {
 
         String goMessageHistoryOutput = exchange.getContext().getGlobalOption(Exchange.MESSAGE_HISTORY_OUTPUT_FORMAT);
         goMessageHistoryOutput = goMessageHistoryOutput == null ? MESSAGE_HISTORY_OUTPUT : goMessageHistoryOutput;
-        sb.append(String.format(goMessageHistoryOutput, loc, routeId, id, label, elapsed));
+        sb.append(String.format(goMessageHistoryOutput, loc, routeId + "/" + id, label, elapsed));
         sb.append("\n");
 
         if (list == null || list.isEmpty()) {
@@ -613,7 +616,7 @@ public final class MessageHelper {
                 // we do not have elapsed time
                 elapsed = 0;
                 sb.append("\t...\n");
-                sb.append(String.format(goMessageHistoryOutput, loc, routeId, id, label, elapsed));
+                sb.append(String.format(goMessageHistoryOutput, loc, routeId + "/" + id, label, elapsed));
                 sb.append("\n");
             }
         } else {
@@ -635,7 +638,7 @@ public final class MessageHelper {
                 label = URISupport.sanitizeUri(StringHelper.limitLength(history.getNode().getLabel(), 100));
                 elapsed = history.getElapsed();
 
-                sb.append(String.format(goMessageHistoryOutput, loc, routeId, id, label, elapsed));
+                sb.append(String.format(goMessageHistoryOutput, loc, routeId + "/" + id, label, elapsed));
                 sb.append("\n");
             }
         }
@@ -651,7 +654,7 @@ public final class MessageHelper {
         if (logStackTrace) {
             sb.append("\nStacktrace\n");
             sb.append(
-                    "---------------------------------------------------------------------------------------------------------------------------------------\n");
+                    "---------------------------------------------------------------------------------------------------------------------------------------");
         }
         return sb.toString();
     }
diff --git a/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_15.adoc b/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_15.adoc
index cae9fd0..011e4d2 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_15.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_15.adoc
@@ -22,16 +22,16 @@ Removed the deprecated `Classic` value from `startupSummaryLevel` enums.
 
 ==== Message History
 
-The message history output now includes a source column, which refers to the Java class/XML file
+The message history output has changed to include source column, which refers to the Java class/XML file
 from the DSL the message was at the given time. (line precise error reporting).
 
-This means there is now 5 columns and the defaults are:
+This default formatting are (Source, ID, Processor, Elapsed):
 ```
-MESSAGE_HISTORY_HEADER = "%-30s %-20s %-20s %-50s %-12s";
-MESSAGE_HISTORY_OUTPUT = "%-30.30s %-20.20s %-20.20s %-50.50s %12.12s";
+    MESSAGE_HISTORY_HEADER = "%-40s %-30s %-50s %-12s";
+    MESSAGE_HISTORY_OUTPUT = "%-40.40s %-30.30s %-50.50s %12.12s";
 ```
 
-If you are using custom sizes then you need to adjust from 4 to 5 columns.
+If you are using custom sizes then you need to adjust accordingly.
 
 === camel-endpointdsl
 
@@ -83,16 +83,16 @@ This should correctly be done with `steps` as child of `from`:
         - log: "message"
 ----
 
+=== camel-jbang
+
+The JBang app that was previously named `CamelJBang` is now named `camel`. It is still possible to use the older name by installing it using `CamelJBang@apache/camel` but this approach is deprecated and should not be used in the future.
+
 === camel-karaf
 
 The `camel-endpointdsl` and `camel-componentdsl` is no longer supported on Apache Karaf.
 
 The `camel-osg-activator` has been removed.
 
-=== camel-jbang
-
-The JBang app that was previously named `CamelJBang` is now named `camel`. It is still possible to use the older name by installing it using `CamelJBang@apache/camel` but this approach is deprecated and should not be used in the future.
-
 === camel-quartz
 
-Removed the option `startDelaySeconds` as this does not work correctly and causes problems if in use.
\ No newline at end of file
+Removed the option `startDelaySeconds` as this does not work correctly and causes problems if in use.