Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-21129

NPE rooted in RestBindingAdviceFactory in camel-support after upgrade 4.6->4.7

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 4.7.0
    • 4.8.0
    • camel-core
    • None
    • Unknown

    Description

      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

      In 4.7, "outJson" remains null here (because of the new if-else) and will lead to the NPE here.

      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.

       

       

      Attachments

        Activity

          People

            davsclaus Claus Ibsen
            jodes Thomas Jodes
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: