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 2024/08/28 10:41:19 UTC

(camel) branch main updated: CAMEL-21129: Fix NPE in rest-dsl when using clientRequestValidation and have outType and json binding turned off. Thanks to Thomas Jodes for the analysis

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 5975895ffda CAMEL-21129: Fix NPE in rest-dsl when using clientRequestValidation and have outType and json binding turned off. Thanks to Thomas Jodes for the analysis
5975895ffda is described below

commit 5975895ffda737e05586c5dab1b1a57ac84ea5c9
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Aug 28 12:41:01 2024 +0200

    CAMEL-21129: Fix NPE in rest-dsl when using clientRequestValidation and have outType and json binding turned off. Thanks to Thomas Jodes for the analysis
---
 .../processor/RestBindingAdviceFactory.java        | 40 ++++++++++------------
 1 file changed, 19 insertions(+), 21 deletions(-)

diff --git a/core/camel-support/src/main/java/org/apache/camel/support/processor/RestBindingAdviceFactory.java b/core/camel-support/src/main/java/org/apache/camel/support/processor/RestBindingAdviceFactory.java
index 969f7dc0136..97d9ace0504 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/processor/RestBindingAdviceFactory.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/processor/RestBindingAdviceFactory.java
@@ -137,9 +137,9 @@ public class RestBindingAdviceFactory {
             RestConfiguration config, String type, Class<?> typeClass, String outType, Class<?> outTypeClass, DataFormat json,
             DataFormat outJson)
             throws Exception {
+
         Class<?> clazz = null;
         boolean useList = false;
-
         if (typeClass != null) {
             useList = typeClass.isArray();
             clazz = useList ? typeClass.getComponentType() : typeClass;
@@ -155,29 +155,27 @@ public class RestBindingAdviceFactory {
             beanIntrospection.setProperty(camelContext, json, "useList",
                     useList);
         }
-
         setAdditionalConfiguration(camelContext, config, json, "json.in.");
 
-        Class<?> outClazz = null;
-        boolean outUseList = false;
-
-        if (outTypeClass != null) {
-            outUseList = outTypeClass.isArray();
-            outClazz = outUseList ? outTypeClass.getComponentType() : outTypeClass;
-        } else if (outType != null) {
-            outUseList = outType.endsWith("[]");
-            String typeName = outUseList ? outType.substring(0, outType.length() - 2) : outType;
-            outClazz = camelContext.getClassResolver().resolveMandatoryClass(typeName);
-        }
-
-        if (outClazz != null) {
-            beanIntrospection.setProperty(camelContext, outJson,
-                    "unmarshalType", outClazz);
-            beanIntrospection.setProperty(camelContext, outJson, "useList",
-                    outUseList);
+        if (outJson != null) {
+            Class<?> outClazz = null;
+            boolean outUseList = false;
+            if (outTypeClass != null) {
+                outUseList = outTypeClass.isArray();
+                outClazz = outUseList ? outTypeClass.getComponentType() : outTypeClass;
+            } else if (outType != null) {
+                outUseList = outType.endsWith("[]");
+                String typeName = outUseList ? outType.substring(0, outType.length() - 2) : outType;
+                outClazz = camelContext.getClassResolver().resolveMandatoryClass(typeName);
+            }
+            if (outClazz != null) {
+                beanIntrospection.setProperty(camelContext, outJson,
+                        "unmarshalType", outClazz);
+                beanIntrospection.setProperty(camelContext, outJson, "useList",
+                        outUseList);
+            }
+            setAdditionalConfiguration(camelContext, config, outJson, "json.out.");
         }
-
-        setAdditionalConfiguration(camelContext, config, outJson, "json.out.");
     }
 
     protected static RestClientRequestValidator lookupRestClientRequestValidator(CamelContext camelContext) {