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 ada36883198 CAMEL-19199: camel-plc4x - Fix NPE with no tags configured.
ada36883198 is described below

commit ada3688319827080682d6a085fa63950cf3f899b
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Mon Mar 27 10:47:25 2023 +0200

    CAMEL-19199: camel-plc4x - Fix NPE with no tags configured.
---
 .../apache/camel/component/plc4x/Plc4XConsumer.java   | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git 
a/components/camel-plc4x/src/main/java/org/apache/camel/component/plc4x/Plc4XConsumer.java
 
b/components/camel-plc4x/src/main/java/org/apache/camel/component/plc4x/Plc4XConsumer.java
index 7f1607eebec..3102ae569fe 100644
--- 
a/components/camel-plc4x/src/main/java/org/apache/camel/component/plc4x/Plc4XConsumer.java
+++ 
b/components/camel-plc4x/src/main/java/org/apache/camel/component/plc4x/Plc4XConsumer.java
@@ -144,17 +144,18 @@ public class Plc4XConsumer extends DefaultConsumer {
 
     private Map<String, String> validateTags() {
         Map<String, String> map = new HashMap<>();
-        for (Map.Entry<String, Object> tag : tags.entrySet()) {
-            if (tag.getValue() instanceof String) {
-                map.put(tag.getKey(), (String) tag.getValue());
+        if (tags != null) {
+            for (Map.Entry<String, Object> tag : tags.entrySet()) {
+                if (tag.getValue() instanceof String) {
+                    map.put(tag.getKey(), (String) tag.getValue());
+                }
+            }
+            if (map.size() != tags.size()) {
+                LOGGER.error("At least one entry does not match the format : 
Map.Entry<String,String> ");
+                return null;
             }
         }
-        if (map.size() != tags.size()) {
-            LOGGER.error("At least one entry does not match the format : 
Map.Entry<String,String> ");
-            return null;
-        } else {
-            return map;
-        }
+        return map;
     }
 
     private ScraperConfigurationTriggeredImpl getScraperConfig(Map<String, 
String> tagList) {

Reply via email to