[
https://issues.apache.org/jira/browse/CAMEL-27731?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen updated CAMEL-27731:
--------------------------------
Fix Version/s: 4.25.0
(was: 4.24.0)
> camel-tahu: deviceIds NPE, unused headerFilterStrategy, endpoint cache,
> metadata issues
> ---------------------------------------------------------------------------------------
>
> Key: CAMEL-27731
> URL: https://issues.apache.org/jira/browse/CAMEL-27731
> Project: Camel
> Issue Type: Bug
> Components: camel-tahu
> Reporter: Claus Ibsen
> Priority: Minor
> Fix For: 4.25.0
>
>
> Found while improving the option descriptions of camel-tahu for CAMEL-23832
> (commit
> https://github.com/apache/camel/commit/f50471af413cfc420ff4485942acd7936e4db900).
> These are separate problems of the component; the descriptions commit only
> documents the current behavior.
> h4. 1. An Edge Node endpoint without deviceIds fails to start with a
> NullPointerException
> {{TahuEdgeEndpoint.getDeviceIdList()}} calls {{deviceIds.split(",")}} without
> a null check. {{TahuEdgeProducer.createClient()}} calls it when an Edge Node
> producer starts ({{TahuEdgeNodeProducer.doStart()}} -> {{clientForStart()}}),
> so a {{tahu-edge:group/node}} endpoint without the {{deviceIds}} option fails
> to start with a {{NullPointerException}}. The option is not marked required,
> and the docs say that an Edge Node does not need Devices.
> Return an empty list when {{deviceIds}} is not set (Tahu's {{EdgeClient}}
> accepts an empty or null list).
> h4. 2. The headerFilterStrategy option of tahu-edge does nothing
> The endpoint has a {{headerFilterStrategy}} option, and
> {{TahuEdgeEndpoint.getHeaderFilterStrategy()}} builds a default one, but no
> code of the component calls it. The payload is made by the type converter
> {{TahuEdgePayloadConverter.messageToSparkplugBPayload()}}, which has its own
> {{headerFilterStrategy}} field; the generated
> {{TahuEdgePayloadConverterLoader}} creates the converter and never sets it,
> so it is always null. A custom strategy set on the endpoint is therefore
> never applied: every header whose name starts with {{CamelTahuMetric.}}, and
> every header whose value is a Tahu {{Metric}}, becomes a metric.
> Apply the strategy of the endpoint when the producer builds the payload (for
> example by building it in {{TahuEdgeProducer.process()}} with the strategy of
> the endpoint), or remove the option.
> h4. 3. Two URIs with the same path share one endpoint, and the options of the
> second change the first
> {{TahuDefaultComponent.createEndpoint()}} caches the endpoints by the
> remaining part of the URI ({{endpoints.computeIfAbsent(remaining, ...)}}).
> For a second URI with the same path but other options (for example
> {{tahu-edge:G/E?useAliases=true}} next to {{tahu-edge:G/E?deviceIds=D1}}), it
> returns the endpoint of the first URI, and
> {{DefaultComponent.createEndpoint(String, Map)}} then sets the options of the
> second URI on that endpoint. The first route then runs with options it did
> not configure, and both URIs resolve to an endpoint whose URI is the first
> one.
> Do not cache endpoints in the component (the CamelContext already caches them
> by URI), or fail when the options differ.
> h4. 4. clientId and servers are marked required where they are not
> {{clientId}} is {{required = true}} for both schemes, but
> {{TahuConfiguration.parseFromUrlString()}} generates a random client ID
> ({{MqttClientId.generate("Camel")}}) when neither the option nor the server
> definition has one. {{servers}} is {{required = true}} for tahu-edge, but a
> Device endpoint ({{tahu-edge:group/node/device}}) never uses it, as its
> producer publishes through the client of its Edge Node endpoint; the YAML
> example of the tahu-edge page has a Device endpoint without it.
> Make {{clientId}} optional, and say in the metadata that {{servers}} is
> required for an Edge Node endpoint only.
> h4. 5. rebirthDebounceDelay is listed for tahu-host, which does not use it
> {{TahuConfiguration.rebirthDebounceDelay}} has {{applicableFor}} tahu-edge
> and tahu-host, but only {{TahuEdgeProducer.createClient()}} reads it;
> {{TahuHostConsumer}} and {{TahuHostApplication}} do not. The option shows up
> in the tahu-host docs and DSL.
> Limit {{applicableFor}} to tahu-edge.
> h4. 6. Wrong defaultValue of bdSeqManager
> The {{bdSeqManager}} option of {{TahuEdgeEndpoint}} has {{defaultValue =
> "org.apache.camel.component.tahu.CamelBdSeqManager"}}, but the class is
> {{org.apache.camel.component.tahu.handlers.CamelBdSeqManager}}.
> Fix the class name in the {{defaultValue}} (or use a {{defaultValueNote}}, as
> the option is an object).
> h4. 7. The producer sets three headers with another type than the documented
> javaType
> {{TahuEdgeProducer.process()}} sets:
> * {{CamelTahuEdgeNodeDescriptor}} to the Tahu {{EdgeNodeDescriptor}} object
> (a {{DeviceDescriptor}} for a Device), while the javaType is {{String}} and
> {{TahuHostConsumer}} sets the descriptor string;
> * {{CamelTahuMessageTimestamp}} to the {{java.util.Date}} of the payload,
> while the javaType is {{Long}} and the consumer sets milliseconds;
> * {{CamelTahuMessageUUID}} to the {{String}} of the payload, while the
> javaType is {{java.util.UUID}} and the consumer sets a {{UUID}}.
> Set the same types as the consumer in the producer (descriptor string,
> {{getTime()}}, {{UUID.fromString()}}), or document both types.
> _Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)