From abac6b2da15eaa2caa0b1e7f36db67fb0ab15756 Mon Sep 17 00:00:00 2001 From: Jency Mary Joseph Date: Mon, 9 Jun 2025 14:53:02 -0700 Subject: [PATCH 1/2] Deprecate DefaultCredentialsProvider.create() due to singleton issues * Add deprecation notice to create() method * Update documentation to clearly explain the risks * Recommend using builder().build() instead --- .../next-release/bugfix-AWSSDKforJavav2-c5cff7a.json | 6 ++++++ .../auth/credentials/DefaultCredentialsProvider.java | 9 +++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 .changes/next-release/bugfix-AWSSDKforJavav2-c5cff7a.json diff --git a/.changes/next-release/bugfix-AWSSDKforJavav2-c5cff7a.json b/.changes/next-release/bugfix-AWSSDKforJavav2-c5cff7a.json new file mode 100644 index 000000000000..29857da34182 --- /dev/null +++ b/.changes/next-release/bugfix-AWSSDKforJavav2-c5cff7a.json @@ -0,0 +1,6 @@ +{ + "type": "bugfix", + "category": "AWS SDK for Java v2", + "contributor": "jencymaryjoseph", + "description": "DefaultCredentialsProvider.create() since it creates Singleton instance" +} diff --git a/core/auth/src/main/java/software/amazon/awssdk/auth/credentials/DefaultCredentialsProvider.java b/core/auth/src/main/java/software/amazon/awssdk/auth/credentials/DefaultCredentialsProvider.java index c0e46006c2a3..083cd93e30d3 100644 --- a/core/auth/src/main/java/software/amazon/awssdk/auth/credentials/DefaultCredentialsProvider.java +++ b/core/auth/src/main/java/software/amazon/awssdk/auth/credentials/DefaultCredentialsProvider.java @@ -74,10 +74,15 @@ private DefaultCredentialsProvider(Builder builder) { } /** - * Returns the singleton instance of the {@link DefaultCredentialsProvider} using the default configuration. - * Configuration can be specified by creating an instance using the {@link #builder()}. If you want to + * Returns the singleton instance of the {@link DefaultCredentialsProvider} using the default configuration. + * Configuration can be specified by creating an instance using the {@link #builder()}. If you want to * create a new instance, use {@link #builder()} instead. + * + * @deprecated The create() method that returns a singleton instance which can cause issues if one client closes the provider + * while others are still using it. Use {@link #builder().build()} to create independent instances, which is the + * safer approach and recommended for most use cases. */ + @Deprecated public static DefaultCredentialsProvider create() { return DEFAULT_CREDENTIALS_PROVIDER; } From 4f76e973599990f0bf6bc0987a312f483903b72a Mon Sep 17 00:00:00 2001 From: jencymaryjoseph <35571282+jencymaryjoseph@users.noreply.github.com> Date: Mon, 9 Jun 2025 15:07:43 -0700 Subject: [PATCH 2/2] Update bugfix-AWSSDKforJavav2-c5cff7a.json --- .changes/next-release/bugfix-AWSSDKforJavav2-c5cff7a.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changes/next-release/bugfix-AWSSDKforJavav2-c5cff7a.json b/.changes/next-release/bugfix-AWSSDKforJavav2-c5cff7a.json index 29857da34182..6774900002ec 100644 --- a/.changes/next-release/bugfix-AWSSDKforJavav2-c5cff7a.json +++ b/.changes/next-release/bugfix-AWSSDKforJavav2-c5cff7a.json @@ -2,5 +2,5 @@ "type": "bugfix", "category": "AWS SDK for Java v2", "contributor": "jencymaryjoseph", - "description": "DefaultCredentialsProvider.create() since it creates Singleton instance" + "description": "Deprecated DefaultCredentialsProvider.create() since it creates Singleton instance" }