[ 
https://issues.apache.org/jira/browse/CAMEL-28029?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Claus Ibsen resolved CAMEL-28029.
---------------------------------
    Resolution: Fixed

> camel-aws2-cw: the client is created in doInit but closed in doStop, 
> putMetricData does not chunk, and the dimensions header is cast element-wise
> -------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-28029
>                 URL: https://issues.apache.org/jira/browse/CAMEL-28029
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-aws2
>            Reporter: Andrea Cosentino
>            Assignee: Andrea Cosentino
>            Priority: Major
>             Fix For: 4.25.0
>
>
> Found during an audit of the cloud components (camel-aws, camel-azure, 
> camel-google, camel-huawei) at commit 7c0644752e17. Every item below was 
> verified against the source.
> h4. 1. A restarted endpoint uses a closed client
> {{Cw2Endpoint}} creates the CloudWatch client in {{doInit()}} and closes it 
> in {{doStop()}}; the class has no {{doStart()}}. {{doInit}} runs once per 
> endpoint, so after a stop/start cycle of the route or of the CamelContext the 
> field still points at the closed client and every send fails. All five 
> sibling modules (kms, sts, eks, ecs, ses) create the client in {{doStart()}}, 
> which pairs with {{doStop()}}.
> Proposed change: move the creation to doStart().
> h4. 2. putMetricData does not enforce or chunk the PutMetricData limits
> {{Cw2Producer.putMetricData}} passes a collection or array body straight 
> through. CloudWatch rejects a request with more than 1000 MetricDatum (and 
> more than 1 MB), so a larger body fails the whole exchange with an opaque AWS 
> error after a full round trip. CAMEL-27307 already gave the empty-body case a 
> clear local message.
> Proposed change: validate locally in the same style, or split into batches of 
> 1000.
> h4. 3. The dimensions header is cast element-wise without a type check
> {{Cw2Producer}} reads {{Cw2Constants.METRIC_DIMENSIONS}} with 
> {{getHeader(..., Map.class)}}, which only proves the header is a Map, then 
> hands {{entry.getValue()}} to {{DimensionFilter.value(String)}}. A 
> Map<String, Integer>, easy to build with setHeader and a Simple expression, 
> throws a bare ClassCastException from inside the producer instead of a typed 
> error naming the header. Same pattern in {{setDimension}} and 
> {{describeAlarmsForMetric}}.
> Proposed change: convert each value through the type converter and fail with 
> a message naming the header.
> h4. 4. The documentation covers no operation
> {{aws2-cw-component.adoc}} is 191 lines whose only example is 
> {{amazonCwClient=#client}}. None of listMetrics, describeAlarms and 
> describeAlarmsForMetric appears anywhere in the page, and there is no 
> putMetricData example.
> h4. 5. Smaller issues
> {{setUseDefaultCredentialsProvider(Boolean)}} assigns to a {{private 
> boolean}} field, so a null from a binder throws NPE on unboxing. There is no 
> way to read metrics back ({{getMetricData}}/{{getMetricStatistics}}) or to 
> manage alarms ({{putMetricAlarm}}, {{deleteAlarms}}, {{setAlarmState}}).
> _Claude Code on behalf of oscerd_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to