[
https://issues.apache.org/jira/browse/CAMEL-26031?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Work on CAMEL-26031 started by Claus Ibsen.
-------------------------------------------
> camel-aws2-cw - a List body of something else fails with a
> ClassCastException, a Date timestamp is ignored, and an upper-case unit is
> sent as null
> --------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-26031
> URL: https://issues.apache.org/jira/browse/CAMEL-26031
> Project: Camel
> Issue Type: Bug
> Components: camel-aws2
> Affects Versions: 4.18.0, 4.22.0, 4.23.0
> Reporter: Claus Ibsen
> Assignee: Claus Ibsen
> Priority: Minor
> Fix For: 4.24.0
>
>
> Found while adding the catalog body types of aws2-cw (CAMEL-24961).
> h4. 1. putMetricData fails with a bare ClassCastException for a List body of
> something else
> putMetricData sends the body when it is a {{MetricDatum}} or a List: a List
> is cast to {{List<MetricDatum>}} unchecked ({{Cw2Producer}}, main
> 07d2e7a987bc, lines 215-216), so a List of anything else fails inside the AWS
> SDK with {{ClassCastException: class java.lang.String cannot be cast to class
> software.amazon.awssdk.services.cloudwatch.model.MetricDatum}}, with no hint.
> A Set or an array of MetricDatum is not a List: it is ignored, and the metric
> comes from the headers.
> Checked on 4.24.0-SNAPSHOT with {{camel run}} against the AWS emulator of
> {{camel infra run aws}}: a List of Strings gave the ClassCastException; a
> MetricDatum and a List of them were sent.
> *Proposed change*: send a Collection or an array of MetricDatum, and fail
> with a message that says what the body must be for anything else.
> h4. 2. A Date in CamelAwsCwMetricTimestamp is ignored
> The catalog says the {{CamelAwsCwMetricTimestamp}} header is a {{Date}}
> ({{Cw2Constants}}, line 38), but the producer reads it as an {{Instant}}
> ({{Cw2Producer}}, line 251), and Camel has no type converter from Date to
> Instant. So a Date header is ignored: the timestamp option is used, or no
> timestamp. Read in the code, not run.
> *Proposed change*: read a Date as well, or say Instant in the catalog.
> h4. 3. An upper-case unit is sent as "null"
> The unit is taken with {{StandardUnit.fromValue}} ({{Cw2Producer}}, line
> 274), which matches the AWS names exactly ({{Count}}, {{Bytes}}).
> {{unit=BYTES}} gives {{UNKNOWN_TO_SDK_VERSION}}, whose text is "null", so the
> request carries the unit "null". {{CwComponentTest}} uses {{unit=BYTES}}, and
> a header hides it there. Read in the code, not run.
> *Proposed change*: match the unit in any case.
> _Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)