This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch feat/camel-tui in repository https://gitbox.apache.org/repos/asf/camel.git
commit ea36365b27dd9d91be7dc098bd1e960d9fca1dec Author: Claus Ibsen <[email protected]> AuthorDate: Mon May 18 10:51:14 2026 +0200 TUI: endpoints tab - fix bidirectional endpoints missing one direction's statistics EndpointDevConsole.findStats() used findFirst() so when an endpoint is used as both consumer (in) and producer (out) only the first matching Statistic was included in the JSON. Changed to return all matching statistics and emit one JSON entry per direction, so both in and out hit counts are captured and shown as separate rows in the TUI endpoints tab. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> --- .../camel/impl/console/EndpointDevConsole.java | 49 +++++++++++++--------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/core/camel-console/src/main/java/org/apache/camel/impl/console/EndpointDevConsole.java b/core/camel-console/src/main/java/org/apache/camel/impl/console/EndpointDevConsole.java index d4863f9d8d7f..1bf56f0c9f47 100644 --- a/core/camel-console/src/main/java/org/apache/camel/impl/console/EndpointDevConsole.java +++ b/core/camel-console/src/main/java/org/apache/camel/impl/console/EndpointDevConsole.java @@ -19,7 +19,6 @@ package org.apache.camel.impl.console; import java.util.Collection; import java.util.List; import java.util.Map; -import java.util.Optional; import org.apache.camel.Endpoint; import org.apache.camel.spi.EndpointRegistry; @@ -61,11 +60,12 @@ public class EndpointDevConsole extends AbstractDevConsole { // shadow-stub uri = uri + " (stub)"; } - var stat = findStats(stats, e.getEndpointUri()); - if (stat.isPresent()) { - var st = stat.get(); - sb.append(String.format("%n %s (remote: %s direction: %s, usage: %s)", uri, remote, st.getDirection(), - st.getHits())); + List<RuntimeEndpointRegistry.Statistic> endpointStats = findStats(stats, e.getEndpointUri()); + if (!endpointStats.isEmpty()) { + for (RuntimeEndpointRegistry.Statistic st : endpointStats) { + sb.append(String.format("%n %s (remote: %s direction: %s, usage: %s)", uri, remote, + st.getDirection(), st.getHits())); + } } else { sb.append(String.format("%n %s (remote: %s)", uri, remote)); } @@ -96,32 +96,41 @@ public class EndpointDevConsole extends AbstractDevConsole { root.put("endpoints", list); Collection<Endpoint> col = reg.getReadOnlyValues(); for (Endpoint e : col) { - JsonObject jo = new JsonObject(); - jo.put("uri", e.getEndpointUri()); - jo.put("remote", e.isRemote()); // NOTE: StubComponent is not available at compilation time. boolean stub = e.getComponent().getClass().getSimpleName().equals("StubComponent"); // NOSONAR - jo.put("stub", stub); - var stat = findStats(stats, e.getEndpointUri()); - if (stat.isPresent()) { - var st = stat.get(); - jo.put("direction", st.getDirection()); - jo.put("hits", st.getHits()); - jo.put("routeId", st.getRouteId()); + boolean remote = e.isRemote(); + List<RuntimeEndpointRegistry.Statistic> endpointStats = findStats(stats, e.getEndpointUri()); + if (!endpointStats.isEmpty()) { + // emit one entry per direction so both in and out hits are captured + for (RuntimeEndpointRegistry.Statistic st : endpointStats) { + JsonObject jo = new JsonObject(); + jo.put("uri", e.getEndpointUri()); + jo.put("remote", remote); + jo.put("stub", stub); + jo.put("direction", st.getDirection()); + jo.put("hits", st.getHits()); + jo.put("routeId", st.getRouteId()); + list.add(jo); + } + } else { + JsonObject jo = new JsonObject(); + jo.put("uri", e.getEndpointUri()); + jo.put("remote", remote); + jo.put("stub", stub); + list.add(jo); } - list.add(jo); } return root; } - private static Optional<RuntimeEndpointRegistry.Statistic> findStats( + private static List<RuntimeEndpointRegistry.Statistic> findStats( List<RuntimeEndpointRegistry.Statistic> stats, String uri) { if (stats == null) { - return Optional.empty(); + return List.of(); } return stats.stream() .filter(s -> uri.equals(s.getUri())) - .findFirst(); + .toList(); } }
