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:56 UTC

[camel] branch master updated (734671a -> 0496de2)

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

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


    from 734671a  Camel-AWS2-KMS: Migrated tests to Junit5
     new a7995eb  CAMEL-14690 - Camel-AWS2: Better logging when checking client instance in the registry, KMS
     new 0496de2  Camel-AWS2-KMS: Fixed CS

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../camel/component/aws2/kms/KMS2Component.java    | 23 +++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)


[camel] 02/02: Camel-AWS2-KMS: Fixed CS

Posted by ac...@apache.org.
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 0496de2ee990edb380ec186102b9a83250436107
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Mar 10 15:50:29 2020 +0100

    Camel-AWS2-KMS: Fixed CS
---
 .../main/java/org/apache/camel/component/aws2/kms/KMS2Component.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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 a725c9a..e093f79 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
@@ -34,7 +34,7 @@ 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


[camel] 01/02: CAMEL-14690 - Camel-AWS2: Better logging when checking client instance in the registry, KMS

Posted by ac...@apache.org.
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");
         }
     }
 }