[
https://issues.apache.org/jira/browse/CAMEL-17618?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17491009#comment-17491009
]
Freeman Yue Fang commented on CAMEL-17618:
------------------------------------------
The previous check
getCamelContext().getEndpoint(getEndpoint().getEndpointUri())
may return an unexpected endpoint based on the getEndpoint().getEndpointUri()
protocol scheme.For the CxfEndpoint, it starts with "http://",so
getCamelContext().getEndpoint(getEndpoint().getEndpointUri()) will
automatically return a HttpEndpoint first, we need to revise the fix a bit like
{code}
if (endpoint == null) {
// endpoint is mandatory
endpoint = CamelContextHelper.mandatoryLookup(getCamelContext(),
name, Endpoint.class);
- if (getCamelContext().getEndpoint(getEndpoint().getEndpointUri())
== null) {
+ if (getCamelContext().getEndpoint(getEndpoint().getEndpointUri())
== null
+ ||
getCamelContext().getEndpoint(getEndpoint().getEndpointUri()) != endpoint) {
getCamelContext().addEndpoint(getEndpoint().getEndpointUri(),
endpoint);
}
}
{code}
to add the expected endpoint referred by the RefEndpoint.
Will send another PR soon
> 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.14.2, 3.11.6, 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.1#820001)