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

davsclaus pushed a commit to branch topology-external-endpoints
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 8cb7605e575962731431f23f29418702641982de
Author: Claus Ibsen <[email protected]>
AuthorDate: Tue Jun 2 11:50:25 2026 +0200

    Narrow exception handling in endpoint metric collection
    
    Move try/catch to per-processor scope so one failing processor does
    not skip the entire route. Add null check on sp.getDestination().
    
    Co-Authored-By: Claude Opus 4.6 <[email protected]>
---
 .../impl/console/RouteTopologyDevConsole.java      | 35 ++++++++++++----------
 1 file changed, 20 insertions(+), 15 deletions(-)

diff --git 
a/core/camel-console/src/main/java/org/apache/camel/impl/console/RouteTopologyDevConsole.java
 
b/core/camel-console/src/main/java/org/apache/camel/impl/console/RouteTopologyDevConsole.java
index cce9071f9b24..0caa74155434 100644
--- 
a/core/camel-console/src/main/java/org/apache/camel/impl/console/RouteTopologyDevConsole.java
+++ 
b/core/camel-console/src/main/java/org/apache/camel/impl/console/RouteTopologyDevConsole.java
@@ -182,20 +182,29 @@ public class RouteTopologyDevConsole extends 
AbstractDevConsole {
             if (!"out".equals(ep.direction())) {
                 continue;
             }
+            String epUri = stripDoubleSlash(URISupport.stripQuery(ep.uri()));
+            ManagedRouteMBean mrb = mcc.getManagedRoute(ep.routeId());
+            if (mrb == null) {
+                continue;
+            }
+            Collection<String> ids;
             try {
-                String epUri = URISupport.stripQuery(ep.uri());
-                ManagedRouteMBean mrb = mcc.getManagedRoute(ep.routeId());
-                if (mrb == null) {
-                    continue;
-                }
-                Collection<String> ids = mrb.processorIds();
-                for (String pid : ids) {
+                ids = mrb.processorIds();
+            } catch (Exception e) {
+                continue;
+            }
+            for (String pid : ids) {
+                try {
                     ManagedSendProcessorMBean sp = 
mcc.getManagedProcessor(pid, ManagedSendProcessorMBean.class);
                     if (sp == null) {
                         continue;
                     }
-                    String dest = URISupport.stripQuery(sp.getDestination());
-                    if (matchEndpointUri(epUri, dest)) {
+                    String dest = sp.getDestination();
+                    if (dest == null) {
+                        continue;
+                    }
+                    dest = stripDoubleSlash(URISupport.stripQuery(dest));
+                    if (epUri.equals(dest)) {
                         String key = ep.routeId() + "|" + ep.uri();
                         long[] existing = metrics.get(key);
                         if (existing != null) {
@@ -205,18 +214,14 @@ public class RouteTopologyDevConsole extends 
AbstractDevConsole {
                             metrics.put(key, new long[] { 
sp.getExchangesTotal(), sp.getExchangesFailed() });
                         }
                     }
+                } catch (Exception e) {
+                    // skip this processor
                 }
-            } catch (Exception e) {
-                // ignore
             }
         }
         return metrics;
     }
 
-    private static boolean matchEndpointUri(String uri1, String uri2) {
-        return stripDoubleSlash(uri1).equals(stripDoubleSlash(uri2));
-    }
-
     private static String stripDoubleSlash(String uri) {
         int idx = uri.indexOf("://");
         if (idx > 0) {

Reply via email to