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 2d22d17caa4 CAMEL-20819: Fix potential NPE in route reloader 2d22d17caa4 is described below commit 2d22d17caa412226160f4b2cd32445d1f6e86b5e Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Thu May 30 19:50:07 2024 +0200 CAMEL-20819: Fix potential NPE in route reloader --- .../camel/support/RouteWatcherReloadStrategy.java | 25 ++++++++++++---------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/core/camel-support/src/main/java/org/apache/camel/support/RouteWatcherReloadStrategy.java b/core/camel-support/src/main/java/org/apache/camel/support/RouteWatcherReloadStrategy.java index be640b7de64..4cfede4ca83 100644 --- a/core/camel-support/src/main/java/org/apache/camel/support/RouteWatcherReloadStrategy.java +++ b/core/camel-support/src/main/java/org/apache/camel/support/RouteWatcherReloadStrategy.java @@ -224,6 +224,7 @@ public class RouteWatcherReloadStrategy extends FileWatcherResourceReloadStrateg return null; } + @SuppressWarnings("unchecked") protected void onRouteReload(Collection<Resource> resources, boolean removeEverything) { // remember all existing resources List<Resource> sources = new ArrayList<>(); @@ -297,19 +298,21 @@ public class RouteWatcherReloadStrategy extends FileWatcherResourceReloadStrateg int started = 0; for (String id : ids) { total++; - String status = getCamelContext().getRouteController().getRouteStatus(id).name(); - if (ServiceStatus.Started.name().equals(status)) { - started++; - } Route route = getCamelContext().getRoute(id); - // use basic endpoint uri to not log verbose details or potential sensitive data - String uri = route.getEndpoint().getEndpointBaseUri(); - uri = URISupport.sanitizeUri(uri); - String loc = route.getSourceLocationShort(); - if (loc == null) { - loc = ""; + if (route != null) { + ServiceStatus status = getCamelContext().getRouteController().getRouteStatus(id); + if (ServiceStatus.Started.equals(status)) { + started++; + } + // use basic endpoint uri to not log verbose details or potential sensitive data + String uri = route.getEndpoint().getEndpointBaseUri(); + uri = URISupport.sanitizeUri(uri); + String loc = route.getSourceLocationShort(); + if (loc == null) { + loc = ""; + } + lines.add(String.format(" %s %s (%s) (source: %s)", status, id, uri, loc)); } - lines.add(String.format(" %s %s (%s) (source: %s)", status, id, uri, loc)); } LOG.info(String.format("Routes reloaded summary (total:%s started:%s)", total, started)); // if we are default/verbose then log each route line