This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new e9b4ab098dd CAMEL-18643 - AWS Health Check: Use AwsServiceException 
instead of SdkClientException for health check - AWS EC2
e9b4ab098dd is described below

commit e9b4ab098ddb630af01dba8a5568625048e51953
Author: Andrea Cosentino <[email protected]>
AuthorDate: Tue Nov 22 09:37:20 2022 +0100

    CAMEL-18643 - AWS Health Check: Use AwsServiceException instead of 
SdkClientException for health check - AWS EC2
    
    Signed-off-by: Andrea Cosentino <[email protected]>
---
 .../org/apache/camel/component/aws2/ec2/AWS2EC2HealthCheck.java  | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git 
a/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/AWS2EC2HealthCheck.java
 
b/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/AWS2EC2HealthCheck.java
index 5e2a16d20ec..b861a515b39 100644
--- 
a/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/AWS2EC2HealthCheck.java
+++ 
b/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/AWS2EC2HealthCheck.java
@@ -22,6 +22,7 @@ import java.util.Map;
 import org.apache.camel.component.aws2.ec2.client.AWS2EC2ClientFactory;
 import org.apache.camel.health.HealthCheckResultBuilder;
 import org.apache.camel.impl.health.AbstractHealthCheck;
+import org.apache.camel.util.ObjectHelper;
 import software.amazon.awssdk.awscore.exception.AwsServiceException;
 import software.amazon.awssdk.regions.Region;
 import software.amazon.awssdk.services.ec2.Ec2Client;
@@ -59,13 +60,19 @@ public class AWS2EC2HealthCheck extends AbstractHealthCheck 
{
         } catch (AwsServiceException e) {
             builder.message(e.getMessage());
             builder.error(e);
+            if (ObjectHelper.isNotEmpty(e.statusCode())) {
+                builder.detail(SERVICE_STATUS_CODE, e.statusCode());
+            }
+            if (ObjectHelper.isNotEmpty(e.awsErrorDetails().errorCode())) {
+                builder.detail(SERVICE_ERROR_CODE, 
e.awsErrorDetails().errorCode());
+            }
             builder.down();
+            return;
         } catch (Exception e) {
             builder.error(e);
             builder.down();
             return;
         }
         builder.up();
-
     }
 }

Reply via email to