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

davsclaus pushed a commit to branch camel-4.4.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-4.4.x by this push:
     new 9b7dea383dd CAMEL-21044: Fix missing Azure Service Bus FQNS 
configuration (#15022)
9b7dea383dd is described below

commit 9b7dea383dd1992a96ef795f2ec233c69d4c8066
Author: Dylan Piergies <dylan.pierg...@gmail.com>
AuthorDate: Tue Aug 6 08:29:22 2024 +0100

    CAMEL-21044: Fix missing Azure Service Bus FQNS configuration (#15022)
    
    The Azure Service Bus client requires that a FQNS be specified when not
    using a connection string.
---
 .../azure/servicebus/client/ServiceBusClientFactory.java | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git 
a/components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/client/ServiceBusClientFactory.java
 
b/components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/client/ServiceBusClientFactory.java
index 225f61da1c0..ae0a79bb3d6 100644
--- 
a/components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/client/ServiceBusClientFactory.java
+++ 
b/components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/client/ServiceBusClientFactory.java
@@ -21,10 +21,8 @@ import com.azure.identity.DefaultAzureCredentialBuilder;
 import com.azure.messaging.servicebus.ServiceBusClientBuilder;
 import com.azure.messaging.servicebus.ServiceBusReceiverAsyncClient;
 import com.azure.messaging.servicebus.ServiceBusSenderAsyncClient;
-import org.apache.camel.component.azure.servicebus.CredentialType;
 import org.apache.camel.component.azure.servicebus.ServiceBusConfiguration;
 import org.apache.camel.component.azure.servicebus.ServiceBusType;
-import org.apache.camel.util.ObjectHelper;
 
 public final class ServiceBusClientFactory {
 
@@ -57,16 +55,12 @@ public final class ServiceBusClientFactory {
         String fullyQualifiedNamespace = 
configuration.getFullyQualifiedNamespace();
         TokenCredential credential = configuration.getTokenCredential();
 
-        if 
(configuration.getCredentialType().equals(CredentialType.CONNECTION_STRING)) {
-            builder.connectionString(configuration.getConnectionString());
-        } else if 
(configuration.getCredentialType().equals(CredentialType.TOKEN_CREDENTIAL)) {
-            // If the FQNS and credential are available, use those to connect
-            if (ObjectHelper.isNotEmpty(fullyQualifiedNamespace) && 
ObjectHelper.isNotEmpty(credential)) {
-                builder.credential(fullyQualifiedNamespace, credential);
-            }
-        } else {
-            builder.credential(new DefaultAzureCredentialBuilder().build());
+        switch (configuration.getCredentialType()) {
+            case CONNECTION_STRING -> 
builder.connectionString(configuration.getConnectionString());
+            case TOKEN_CREDENTIAL -> 
builder.credential(fullyQualifiedNamespace, credential);
+            case AZURE_IDENTITY -> builder.credential(fullyQualifiedNamespace, 
new DefaultAzureCredentialBuilder().build());
         }
+
         return builder;
     }
 

Reply via email to