Claus Ibsen created CAMEL-27690:
-----------------------------------
Summary: camel-cometd: producer restart, silent drops,
baseResource parsing, CORS path, unused options
Key: CAMEL-27690
URL: https://issues.apache.org/jira/browse/CAMEL-27690
Project: Camel
Issue Type: Bug
Components: camel-cometd
Reporter: Claus Ibsen
Fix For: 4.24.0
Found while improving the option descriptions of camel-cometd for CAMEL-23832
(commit
https://github.com/apache/camel/commit/ebaf6895c4d1f98fff1e4beaea012afd91790992).
These are separate problems of the component; the descriptions commit only
documents the current behavior.
h4. 1. The producer does not clean up its service when it stops
{{CometdProducer.doStop()}} calls {{super.stop()}} instead of
{{super.doStop()}}; as the producer is already stopping, that call does
nothing. It also keeps its {{ProducerService}} and does not disconnect the
local session of that service. When the producer is restarted, {{doStart()}}
reuses the old service: if the server of the host and port was stopped and
started again in between, the producer publishes with the local session of the
old Bayeux server.
Proposed change: do in the producer what CAMEL-25278 did for
{{CometdConsumer.doStop()}}: remove the service, disconnect its local session,
set the field to null and call {{super.doStop()}}.
h4. 2. The producer drops the message silently when the channel does not exist
{{CometdProducer.ProducerService.process()}} looks the channel up with
{{bayeux.getChannel(channelName)}} and does nothing when it is null, which is
the case when no consumer and no client is subscribed to the channel. The
exchange completes without a log line or an error.
Proposed change: log at DEBUG (or WARN once) that the message was not
published, or create the channel with {{createChannelIfAbsent}}.
h4. 3. baseResource is parsed with split(":")
{{CometdComponent.createServletForConnector()}} splits {{baseResource}} with
{{split(":")}} and reads {{resources[1]}} in a debug log. A value without {{:}}
fails with an {{ArrayIndexOutOfBoundsException}} when the server starts, a
prefix other than {{file}} or {{classpath}} is ignored without a warning, and a
Windows path such as {{file:C:/web}} is cut to {{C}}.
Proposed change: split at the first {{:}} only, and fail with a clear message
for a missing or unknown prefix.
h4. 4. crossOriginFilterOn without filterPath does nothing
{{CometdComponent.applyCrossOriginFiltering()}} adds the filter with
{{endpoint.getFilterPath()}}, which is null by default. Jetty's
{{FilterMapping.appliesTo()}} skips a null path spec, so the filter applies to
no request and the server sends no CORS headers, without a warning.
Proposed change: default {{filterPath}} to {{/cometd/*}} (the path of the
CometD servlet), or fail at startup when it is missing.
h4. 5. multiFrameInterval, jsonCommented and logLevel have no effect
{{CometdComponent.createServletForConnector()}} passes them to
{{CometDServlet}} as the init parameters {{multiFrameInterval}},
{{JSONCommented}} and {{logLevel}}. CometD 9.0.1 does not read any of them
(they were removed in older CometD versions), so the options do nothing.
Proposed change: deprecate the three options and stop passing them, with an
entry in the upgrade guide.
h4. 6. sslPassword and sslKeyPassword mean the opposite of camel-jetty
{{CometdComponent.getSslSocketConnector()}} uses {{sslKeyPassword}} as the
keystore password ({{setKeyStorePassword}}) and {{sslPassword}} as the key
password ({{setKeyManagerPassword}}). {{JettyHttpComponent}} uses options with
the same names the other way round. A user who moves a configuration from
camel-jetty to camel-cometd gets a keystore that does not open when the two
passwords differ.
Proposed change: decide which meaning is right; swapping them is a behavior
change that needs an upgrade guide entry.
h4. 7. Server options of later endpoints are ignored silently
{{baseResource}}, {{timeout}}, {{interval}}, {{maxInterval}},
{{allowedTransports}} and the cross-origin options configure the server that
{{CometdComponent.connect()}} creates for a scheme, host and port. Only the
first endpoint that starts this server is used; another endpoint with other
values on the same host and port is ignored without a warning.
Proposed change: log a WARN when an endpoint has server options that differ
from the server it shares.
h4. 8. Metadata of channelName and port
The {{CometdEndpoint}} constructor sets {{channelName}} to the whole remaining
part of the URI ({{host:port/path}}), and the field is never read: the producer
and consumer use the URI path as the channel. {{port}} is marked required, but
{{getPort()}} defaults to 80 for {{cometd}} and 443 for {{cometds}} when it is
missing.
Proposed change: set {{channelName}} to the path (or read it), and drop the
required flag of {{port}} or document the defaults.
_Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)