You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2020/03/10 14:50:57 UTC
[camel] 01/02: CAMEL-14690 - Camel-AWS2: Better logging when
checking client instance in the registry, KMS
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit a7995ebaa2b62bf089ea6767371ac3b9851cf4fc
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Mar 10 15:47:44 2020 +0100
CAMEL-14690 - Camel-AWS2: Better logging when checking client instance in the registry, KMS
---
.../camel/component/aws2/kms/KMS2Component.java | 25 ++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/components/camel-aws2-kms/src/main/java/org/apache/camel/component/aws2/kms/KMS2Component.java b/components/camel-aws2-kms/src/main/java/org/apache/camel/component/aws2/kms/KMS2Component.java
index fee7ae5..a725c9a 100644
--- a/components/camel-aws2-kms/src/main/java/org/apache/camel/component/aws2/kms/KMS2Component.java
+++ b/components/camel-aws2-kms/src/main/java/org/apache/camel/component/aws2/kms/KMS2Component.java
@@ -24,6 +24,9 @@ import org.apache.camel.Endpoint;
import org.apache.camel.spi.Metadata;
import org.apache.camel.spi.annotations.Component;
import org.apache.camel.support.DefaultComponent;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import software.amazon.awssdk.services.kms.KmsClient;
/**
@@ -31,7 +34,9 @@ import software.amazon.awssdk.services.kms.KmsClient;
*/
@Component("aws2-kms")
public class KMS2Component extends DefaultComponent {
-
+
+ private static final Logger LOG = LoggerFactory.getLogger(KMS2Component.class);
+
@Metadata
private KMS2Configuration configuration = new KMS2Configuration();
@@ -51,7 +56,7 @@ public class KMS2Component extends DefaultComponent {
KMS2Endpoint endpoint = new KMS2Endpoint(uri, this, configuration);
setProperties(endpoint, parameters);
- checkAndSetRegistryClient(configuration);
+ checkAndSetRegistryClient(configuration, endpoint);
if (configuration.getKmsClient() == null && (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) {
throw new IllegalArgumentException("Amazon kms client or accessKey and secretKey must be specified");
}
@@ -70,10 +75,18 @@ public class KMS2Component extends DefaultComponent {
this.configuration = configuration;
}
- private void checkAndSetRegistryClient(KMS2Configuration configuration) {
- Set<KmsClient> clients = getCamelContext().getRegistry().findByType(KmsClient.class);
- if (clients.size() == 1) {
- configuration.setKmsClient(clients.stream().findFirst().get());
+ private void checkAndSetRegistryClient(KMS2Configuration configuration, KMS2Endpoint endpoint) {
+ if (ObjectHelper.isEmpty(endpoint.getConfiguration().getKmsClient())) {
+ LOG.debug("Looking for an KmsClient instance in the registry");
+ Set<KmsClient> clients = getCamelContext().getRegistry().findByType(KmsClient.class);
+ if (clients.size() == 1) {
+ LOG.debug("Found exactly one KmsClient instance in the registry");
+ configuration.setKmsClient(clients.stream().findFirst().get());
+ } else {
+ LOG.debug("No KmsClient instance in the registry");
+ }
+ } else {
+ LOG.debug("KmsClient instance is already set at endpoint level: skipping the check in the registry");
}
}
}