[ 
https://issues.apache.org/jira/browse/CAMEL-13941?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16922581#comment-16922581
 ] 

Julien Greffe edited comment on CAMEL-13941 at 9/4/19 2:51 PM:
---------------------------------------------------------------

We're in a case where we use a specific class overriding 
FailoverTargetSelector.selectConduit()
 
[https://github.com/apache/cxf/blob/cxf-3.2.4/rt/features/clustering/src/main/java/org/apache/cxf/clustering/FailoverTargetSelector.java#L132]

At camelContext startup, this endpoint doesn't exist, but we should being able 
to start the camelContext successfully.

Here is an example :
{code:java}
 <reference id="locatorFeature" <reference id="locatorFeature" 
interface="org.talend.esb.servicelocator.cxf.LocatorFeature" />
 <cxf:cxfEndpoint id="customerClient" wsdlURL="example.wsdl" 
xmlns:tns="http://www.example.com/"; endpointName="tns:CustomerServicePort" 
serviceName="tns:CustomerServiceService" 
serviceClass="com.example.CustomerService" address="locator://">
 
<cxf:features>
 <ref component-id="locatorFeature" />
 </cxf:features>

 <cxf:properties> <entry key="schema-validation-enabled" value="true" />
 </cxf:properties>
 </cxf:cxfEndpoint>

 <camelContext id="BlueprintLocatorContext" 
xmlns="http://camel.apache.org/schema/blueprint";>
 <route id="blueprintLocatorRoute"> <from uri="timer:myTimer?period=10s" />
 <log message="Scheduled_message" />
 <transform>
 <simple>111</simple>
 </transform>
 <removeHeaders pattern="*" />
 <to uri="cxf:bean:customerClient?synchronous=true" />
 </route>

 </camelContext>{code}
When starting, the custom code overrides selectConduit, and we would like to 
avoid any exception (even if the endpoint isn't available) to have the 
camelContext starting properly and having a bundle status {{Active}}.

One tested behaviour is returning a null {{Conduit}}, and adding a nullity test 
on CXF, and have the expected behaviour.

 

Maybe I pointed the wrong place, or our implementation isn't effective?


was (Author: jgreffe):
We're in a case where we use a specific class overriding 
FailoverTargetSelector.selectConduit()
 
[https://github.com/apache/cxf/blob/cxf-3.2.4/rt/features/clustering/src/main/java/org/apache/cxf/clustering/FailoverTargetSelector.java#L132]

At camelContext startup, this endpoint doesn't exist, but we should being able 
to start the camelContext successfully.

Here is an example :
{code:java}
 <reference id="locatorFeature" <reference id="locatorFeature" 
interface="org.talend.esb.servicelocator.cxf.LocatorFeature" />
 <cxf:cxfEndpoint id="customerClient" wsdlURL="example.wsdl" 
xmlns:tns="http://www.example.com/"; endpointName="tns:CustomerServicePort" 
serviceName="tns:CustomerServiceService" 
serviceClass="com.example.CustomerService" address="locator://">
 
<cxf:features>
 <ref component-id="locatorFeature" />
 </cxf:features>

 <cxf:properties> <entry key="schema-validation-enabled" value="true" />
 </cxf:properties>
 </cxf:cxfEndpoint>

 <camelContext id="BlueprintLocatorContext" 
xmlns="http://camel.apache.org/schema/blueprint";>
 <route id="blueprintLocatorRoute"> <from uri="timer:myTimer?period=10s" />
 <log message="Scheduled_message" />
 <transform>
 <simple>111</simple>
 </transform>
 <removeHeaders pattern="*" />
 <to uri="cxf:bean:customerClient?synchronous=true" />
 </route>

 </camelContext>{code}

When starting, the custom code overrides selectConduit, and we would like to 
avoid any exception (even if the endpoint isn't available) to have the 
camelContext starting properly and having a bundle status {{Active}}.

Maybe I pointed the wrong place, or our implementation isn't effective?

> NullPointerException when Conduit is null
> -----------------------------------------
>
>                 Key: CAMEL-13941
>                 URL: https://issues.apache.org/jira/browse/CAMEL-13941
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-cxf
>    Affects Versions: 2.20.1, 2.21.2, 2.23.1, 2.24.1
>            Reporter: Julien Greffe
>            Priority: Minor
>
> Hello,
> the CxfProducer.doStart() retrieves a Conduit.
> If this Conduit is null, should we still throw a NullPointerException or, 
> should we check nullity before condition?
> {code:java}
> Conduit conduit = client.getConduit();
>         if (conduit.getClass().getName().endsWith("JMSConduit")) {
> ...
> }{code}
> https://github.com/apache/camel/blob/camel-2.21.2/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java#L87
> https://github.com/apache/camel/blob/camel-2.23.1/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java#L87
> https://github.com/apache/camel/blob/camel-2.24.1/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java#L87
> Thanks for your point of view.



--
This message was sent by Atlassian Jira
(v8.3.2#803003)

Reply via email to