[
https://issues.apache.org/jira/browse/CAMEL-17618?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17901783#comment-17901783
]
Gordon Freeman edited comment on CAMEL-17618 at 11/28/24 8:17 PM:
------------------------------------------------------------------
I think there is a bug in the code that was added in this task, method
{*}RefEndpoint.doInit{*}.
You used the condition
{code:java}
getCamelContext().getEndpoint(getEndpoint().getEndpointUri()) == null
{code}
which assumes that if the *getEndpoint* method does not find an endpoint, it
will return {*}null{*}.
According to Javadoc it does not return null. It may create a new endpoint, or
throw an error.
In my case it throws an error because for *cxfEndpoint* the *EndpointUri*
passed is taken from the *address* attribute (i.e. "/getMyCxfEndpoint"), which
in my case does not contain the scheme URL.
I run camel in Tomcat and Spring, also configured
{*}org.apache.cxf.transport.servlet.CXFServlet{*}, and
{code:java}
address="/getMyCxfEndpoint"
{code}
means what I am creating SOAP web service with the http port provided by
tomcat, so there is not scheme (like [http://|http:]) in the address.
You should probably use the *CamelContext.hasEndpoint* method instead of
{*}getEndpoint{*}.
was (Author: JIRAUSER306179):
I think there is a bug in the code that was added in this task, method
{*}RefEndpoint.doInit{*}.
You used the condition
{code:java}
getCamelContext().getEndpoint(getEndpoint().getEndpointUri()) == null
{code}
which assumes that if the *getEndpoint* method does not find an endpoint, it
will return {*}null{*}.
According to Javadoc it does not return null. It may create a new endpoint, or
throw an error.
In my case it throws an error because for *cxfEndpoint* the *EndpointUri*
passed is taken from the *address* attribute (i.e. "/getMyCxfEndpoint"), which
in my case does not contain the scheme URL.
I run camel in Tomcat ans Spring, also configured
{*}org.apache.cxf.transport.servlet.CXFServlet{*}, and
{code:java}
address="/getMyCxfEndpoint"
{code}
means what I am creating SOAP web service with the http port provided by
tomcat, so there is not scheme (like [http://|http:]) in the address.
You should probably use the *CamelContext.hasEndpoint* method instead of
{*}getEndpoint{*}.
> camel-ref: only add the endpoint into camelContext when not exist
> -----------------------------------------------------------------
>
> Key: CAMEL-17618
> URL: https://issues.apache.org/jira/browse/CAMEL-17618
> Project: Camel
> Issue Type: Bug
> Components: camel-core
> Affects Versions: 3.15.0
> Reporter: Freeman Yue Fang
> Assignee: Freeman Yue Fang
> Priority: Minor
> Fix For: 3.11.6, 3.14.2, 3.16.0
>
>
> Currently camel-ref endpoint always adds the underlying endpoint like
> getCamelContext().addEndpoint(getEndpoint().getEndpointUri(), endpoint);
> We should check if it exists or not firstly like
> if (getCamelContext().getEndpoint(getEndpoint().getEndpointUri()) ==
> null) {
> getCamelContext().addEndpoint(getEndpoint().getEndpointUri(),
> endpoint);
> }
> Because if we re-add the same endpoint, this endpoint actually will be stopped
--
This message was sent by Atlassian Jira
(v8.20.10#820010)