Thomas Jodes created CAMEL-21129:
------------------------------------
Summary: 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
{{Rest Route creation fails with a NPE, setup using
restConfiguration().{color:#d8d8d8}{color:#ffffff}clientRequestValidation{color}{color}(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]
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]|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().{}}}{{{}{color:#d8d8d8}{color:#ffffff}clientRequestValidation{color}{color}{}}}{{{}(false)
will overgo the critical unit of code.{}}}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)