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

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


The following commit(s) were added to refs/heads/camel-3.x by this push:
     new 52c4fb4e22b CAMEL-19199: camel-plc4x - Fix NPE with no tags configured.
52c4fb4e22b is described below

commit 52c4fb4e22b5fc1509307c3d89700c8d53b9f279
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Mon Mar 27 10:46:47 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