From d62322c2acf167d1a43c123f58fc41907f3d129c Mon Sep 17 00:00:00 2001 From: Max Smiley Date: Wed, 24 Jul 2024 22:11:44 +0000 Subject: [PATCH] Fix ContextBuilder bug when using credentials supplier with azureblob --- .../src/main/java/org/jclouds/ContextBuilder.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/org/jclouds/ContextBuilder.java b/core/src/main/java/org/jclouds/ContextBuilder.java index 7c6cbc59913..6588a56ae0d 100644 --- a/core/src/main/java/org/jclouds/ContextBuilder.java +++ b/core/src/main/java/org/jclouds/ContextBuilder.java @@ -74,6 +74,7 @@ import org.jclouds.providers.config.BindProviderMetadataContextAndCredentials; import org.jclouds.providers.internal.UpdateProviderMetadataFromProperties; import org.jclouds.reflect.Invocation; +import org.jclouds.rest.ApiContext; import org.jclouds.rest.ConfiguresCredentialStore; import org.jclouds.rest.ConfiguresHttpApi; import org.jclouds.rest.HttpApiMetadata; @@ -364,10 +365,16 @@ private Properties currentStateToUnexpandedProperties() { defaults.setProperty(PROPERTY_API, apiMetadata.getName()); defaults.setProperty(PROPERTY_API_VERSION, apiVersion); defaults.setProperty(PROPERTY_BUILD_VERSION, buildVersion); - if (identity.isPresent()) - defaults.setProperty(PROPERTY_IDENTITY, identity.get()); - if (credential != null) - defaults.setProperty(PROPERTY_CREDENTIAL, credential); + if (credentialsSupplierOption.isPresent()) { + Credentials credentials = credentialsSupplierOption.get().get(); + defaults.setProperty(PROPERTY_IDENTITY, credentials.identity); + defaults.setProperty(PROPERTY_CREDENTIAL, credentials.credential); + } else { + if (identity.isPresent()) + defaults.setProperty(PROPERTY_IDENTITY, identity.get()); + if (credential != null) + defaults.setProperty(PROPERTY_CREDENTIAL, credential); + } if (overrides.isPresent()) putAllAsString(overrides.get(), defaults); putAllAsString(propertiesPrefixedWithJcloudsApiOrProviderId(getSystemProperties(), apiMetadata.getId(), providerId), defaults);