You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2020/12/11 17:35:50 UTC

[camel-kafka-connector] 01/02: Prevent an NPE in the ssh transformation the unlikely case value is null

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

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-kafka-connector.git

commit c773da0ce96703a7f9af18f08c3c8e5db9578992
Author: Otavio Rodolfo Piske <op...@redhat.com>
AuthorDate: Fri Dec 11 17:50:57 2020 +0100

    Prevent an NPE in the ssh transformation the unlikely case value is null
---
 .../apache/camel/kafkaconnector/ssh/transformers/SshTransforms.java   | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/connectors/camel-ssh-kafka-connector/src/main/java/org/apache/camel/kafkaconnector/ssh/transformers/SshTransforms.java b/connectors/camel-ssh-kafka-connector/src/main/java/org/apache/camel/kafkaconnector/ssh/transformers/SshTransforms.java
index 8f14538..bb41a9a 100644
--- a/connectors/camel-ssh-kafka-connector/src/main/java/org/apache/camel/kafkaconnector/ssh/transformers/SshTransforms.java
+++ b/connectors/camel-ssh-kafka-connector/src/main/java/org/apache/camel/kafkaconnector/ssh/transformers/SshTransforms.java
@@ -40,7 +40,7 @@ public class SshTransforms<R extends ConnectRecord<R>> implements Transformation
     public R apply(R r) {
         Object value = r.value();
 
-        if (r.value() instanceof ByteArrayInputStream) {
+        if (value instanceof ByteArrayInputStream) {
             LOG.debug("Converting record from Ssh Body Result to text");
             ByteArrayInputStream message = (ByteArrayInputStream)r.value();
             String m = null;
@@ -53,7 +53,7 @@ public class SshTransforms<R extends ConnectRecord<R>> implements Transformation
             return r.newRecord(r.topic(), r.kafkaPartition(), null, r.key(), SchemaHelper.buildSchemaBuilderForType(m), m, r.timestamp());
 
         } else {
-            LOG.debug("Unexpected message type: {}", r.value().getClass());
+            LOG.debug("Unexpected message type: {}", value == null ? "null instance" : value.getClass());
 
             return r;
         }