You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2019/12/09 15:37:06 UTC

[camel] branch camel-3.0.x updated: [CAMEL-14267] Fix a nullPointerException in convertIfRequired (#3393)

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

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


The following commit(s) were added to refs/heads/camel-3.0.x by this push:
     new a72dfa9  [CAMEL-14267] Fix a nullPointerException in convertIfRequired (#3393)
a72dfa9 is described below

commit a72dfa9f81993397332d1f157aa26fbac927cf3f
Author: tfabien <ft...@gmail.com>
AuthorDate: Mon Dec 9 16:35:53 2019 +0100

    [CAMEL-14267] Fix a nullPointerException in convertIfRequired (#3393)
    
    Fix a nullPointerException in convertIfRequired when boddy is null
---
 .../src/main/java/org/apache/camel/processor/ContractAdvice.java        | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/core/camel-base/src/main/java/org/apache/camel/processor/ContractAdvice.java b/core/camel-base/src/main/java/org/apache/camel/processor/ContractAdvice.java
index d3676c2..e314b77 100644
--- a/core/camel-base/src/main/java/org/apache/camel/processor/ContractAdvice.java
+++ b/core/camel-base/src/main/java/org/apache/camel/processor/ContractAdvice.java
@@ -142,7 +142,7 @@ public class ContractAdvice implements CamelInternalProcessorAdvice {
     private boolean convertIfRequired(Message message, DataType type) throws Exception {
         // TODO for better performance it may be better to add TypeConverterTransformer
         // into transformer registry automatically to avoid unnecessary scan in transformer registry
-        if (type != null && type.isJavaType() && type.getName() != null) {
+        if (type != null && type.isJavaType() && type.getName() != null && message != null && message.getBody() != null) {
             CamelContext context = message.getExchange().getContext();
             Class<?> typeJava = getClazz(type.getName(), context);
             if (!typeJava.isAssignableFrom(message.getBody().getClass())) {