You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (Jira)" <ji...@apache.org> on 2024/08/28 10:42:00 UTC
[jira] [Resolved] (CAMEL-21129) NPE rooted in RestBindingAdviceFactory in camel-support after upgrade 4.6->4.7
[ https://issues.apache.org/jira/browse/CAMEL-21129?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Claus Ibsen resolved CAMEL-21129.
---------------------------------
Resolution: Fixed
> NPE rooted in RestBindingAdviceFactory in camel-support after upgrade 4.6->4.7
> ------------------------------------------------------------------------------
>
> Key: CAMEL-21129
> URL: https://issues.apache.org/jira/browse/CAMEL-21129
> Project: Camel
> Issue Type: Bug
> Components: camel-core
> Affects Versions: 4.7.0
> Reporter: Thomas Jodes
> Assignee: Claus Ibsen
> Priority: Minor
> Fix For: 4.8.0
>
>
> Rest Route creation fails with a NPE, setup using
> {{restConfiguration().clientRequestValidation(true) }}
> with a JSON-binding to a Java type like:
> {{rest("/foo").get("/bar").outType(MyType.class).to("bean:one?method=baz").}}
>
> *Root cause:* Changes from 4.6 to 4.7 in RestBindingAdvisorFactory#build(...)
> local variable "outJson" is always null, leading to the NPE for sure at the line seen in the exception trace below.
> {*}In 4.6{*}, "outJson" [is created for sure here|https://github.com/apache/camel/blob/581b94a8d326e381d6c58cfe8ce80c92168ac29a/core/camel-support/src/main/java/org/apache/camel/support/processor/RestBindingAdviceFactory.java#L76]
> {*}In 4.7{*}, "outJson" [remains null here|https://github.com/apache/camel/blob/a2212f39466d7ef9185b6557f872ca9a8a7da3b8/core/camel-support/src/main/java/org/apache/camel/support/processor/RestBindingAdviceFactory.java#L70] (because of the new if-else) and will [lead to the NPE here|https://github.com/apache/camel/blob/a2212f39466d7ef9185b6557f872ca9a8a7da3b8/core/camel-support/src/main/java/org/apache/camel/support/processor/RestBindingAdviceFactory.java#L174].
> {{Caused by: java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "target" is null}}
> {{ at org.apache.camel.impl.engine.IntrospectionSupport.setProperty(IntrospectionSupport.java:551)}}
> {{ at org.apache.camel.impl.engine.IntrospectionSupport.setProperty(IntrospectionSupport.java:691)}}
> {{ at org.apache.camel.impl.engine.DefaultBeanIntrospection.setProperty(DefaultBeanIntrospection.java:220)}}
> {{ at org.apache.camel.support.processor.RestBindingAdviceFactory.setupJson(RestBindingAdviceFactory.java:174)}}
> {{ at org.apache.camel.support.processor.RestBindingAdviceFactory.build(RestBindingAdviceFactory.java:80)}}
>
> {{{}Setting restConfiguration().{}}}clientRequestValidation{{{}(false){}}} will overgo the critical unit of code.
>
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)