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

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


The following commit(s) were added to refs/heads/camel-4.4.x by this push:
     new e8c8cdbfa81 CAMEL-21239: camel-report-maven-plugin - NPE if route does 
not have id
e8c8cdbfa81 is described below

commit e8c8cdbfa811762785d872a9fd7977afadb0e267
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Sep 18 15:38:50 2024 +0200

    CAMEL-21239: camel-report-maven-plugin - NPE if route does not have id
---
 .../src/main/docs/camel-report-maven-plugin.adoc                       | 2 +-
 .../main/java/org/apache/camel/parser/helper/RouteCoverageHelper.java  | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git 
a/catalog/camel-report-maven-plugin/src/main/docs/camel-report-maven-plugin.adoc
 
b/catalog/camel-report-maven-plugin/src/main/docs/camel-report-maven-plugin.adoc
index c0cf076b7c2..ae758180b95 100644
--- 
a/catalog/camel-report-maven-plugin/src/main/docs/camel-report-maven-plugin.adoc
+++ 
b/catalog/camel-report-maven-plugin/src/main/docs/camel-report-maven-plugin.adoc
@@ -284,7 +284,7 @@ public boolean isDumpRouteCoverage() {
 }
 ----
 
-Routes that can be route coveraged must have an unique id assigned, in other 
words you cannot use anonymous routes.
+IMPORTANT: Routes that can be route coveraged **MUST** have a unique id 
assigned, in other words you cannot use anonymous routes.
 
 You do this using `routeId` in Java DSL:
 
diff --git 
a/catalog/camel-route-parser/src/main/java/org/apache/camel/parser/helper/RouteCoverageHelper.java
 
b/catalog/camel-route-parser/src/main/java/org/apache/camel/parser/helper/RouteCoverageHelper.java
index ec4cbcd20d3..ceb3d5bc265 100644
--- 
a/catalog/camel-route-parser/src/main/java/org/apache/camel/parser/helper/RouteCoverageHelper.java
+++ 
b/catalog/camel-route-parser/src/main/java/org/apache/camel/parser/helper/RouteCoverageHelper.java
@@ -67,7 +67,8 @@ public final class RouteCoverageHelper {
                 NodeList routes = dom.getElementsByTagName("route");
                 for (int i = 0; i < routes.getLength(); i++) {
                     Node route = routes.item(i);
-                    String id = 
route.getAttributes().getNamedItem("id").getNodeValue();
+                    Node n = route.getAttributes().getNamedItem("id");
+                    String id = n != null ? n.getNodeValue() : null;
                     if (routeId.equals(id)) {
                         // parse each route and build a List<CoverageData> for 
line by line coverage data
                         AtomicInteger counter = new AtomicInteger();

Reply via email to