Andrea Cosentino created CAMEL-28046:
----------------------------------------

             Summary: camel-aws: extract a base class for the 25 copy-pasted 
producer health checks into camel-aws-common
                 Key: CAMEL-28046
                 URL: https://issues.apache.org/jira/browse/CAMEL-28046
             Project: Camel
          Issue Type: Task
          Components: camel-aws
            Reporter: Andrea Cosentino


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.

camel-aws ships 25 {{*ProducerHealthCheck}} classes. 21 of them contain the 
same block verbatim:

{code:java}
if (ObjectHelper.isNotEmpty(e.awsErrorDetails()) && 
ObjectHelper.isNotEmpty(e.awsErrorDetails().errorCode())) {
    builder.detail(SERVICE_ERROR_CODE, e.awsErrorDetails().errorCode());
}
{code}

Only the client call and the region-metadata lookup differ between them. None 
of the 25 uses {{AwsExceptionUtil.errorCode}}, although {{camel-aws-common}} 
already owns it for exactly this null-guard and 30 producers call it.

The duplication is not only a maintenance cost, it hides defects: the SES 
health check is missing the {{return}} after {{builder.down()}} in its 
AwsServiceException branch and therefore reports UP on a service error, which 
no reviewer spotted across 25 near-identical files. Several modules also probe 
with an API unrelated to the configured operation, two of them billed.

Proposed change: add an {{AbstractAwsProducerHealthCheck}} to 
{{camel-aws-common}} that owns the region check, the exception handling, the 
two details and the UP/DOWN decision, leaving each module to supply only its 
probe call; migrate the 25 classes to it. A single place also makes it possible 
to state and enforce the probe policy: never a billed API, and an operation 
whose permission the endpoint already needs.

Related: CAMEL-19674 (producer health check for sqs and kinesis), CAMEL-27787, 
CAMEL-27849.

_Claude Code on behalf of oscerd_



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

Reply via email to