You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "James Netherton (Jira)" <ji...@apache.org> on 2020/05/18 09:32:00 UTC

[jira] [Created] (CAMEL-15076) Rest OpenAPI component NPE when using components bound to the registry

James Netherton created CAMEL-15076:
---------------------------------------

             Summary: Rest OpenAPI component NPE when using components bound to the registry
                 Key: CAMEL-15076
                 URL: https://issues.apache.org/jira/browse/CAMEL-15076
             Project: Camel
          Issue Type: Improvement
            Reporter: James Netherton


Not sure if this is a genuine issue or my misunderstanding of how things are supposed to work. I was experimenting with camel-rest-openapi and had a little problem.

The docs state that REST capable components can be discovered from the registry. Is the expectation from users that the components are initialised in some way before they are bound to the registry?

E.g if I do this:
{code:java}
NettyHttpComponent component = new NettyHttpComponent();
camelContext.getRegistry().bind("netty-http", component);
{code}
Then I eventually end up hitting an NPE because NettyHttpComponent does the following in {{createProducer}}, and {{getCamelContext()}} returns null:
{code:java}
RestConfiguration config = CamelContextHelper.getRestConfiguration(getCamelContext(), "netty-http");
{code}
It's easily fixed by doing {{setCamelContext}} on the component before binding it to the registry. But, do we expect users to do this themselves? Or should camel take care of doing this after it has discovered the component in the registry (E.g after [this|https://github.com/apache/camel/blob/master/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestEndpoint.java#L346])?



--
This message was sent by Atlassian Jira
(v8.3.4#803005)