@@ -14,27 +14,22 @@ import aws.smithy.kotlin.runtime.util.PlatformProvider
1414/* *
1515 * A [BearerTokenProvider] that extracts the bearer token from JVM system properties or environment variables.
1616 */
17- public class EnvironmentBearerTokenProvider private constructor (
18- private val sysPropKey : String? ,
17+ public class EnvironmentBearerTokenProvider (
18+ private val sysPropKey : String ,
1919 private val envKey : String ,
2020 private val platform : PlatformProvider = PlatformProvider .System ,
2121) : BearerTokenProvider {
2222 @Deprecated(" This constructor does not support a parameter for a system property key and will be removed in version 1.6.x" )
2323 public constructor (
2424 envKey: String ,
2525 platform: PlatformProvider = PlatformProvider .System ,
26- ) : this (null , envKey, platform)
27-
28- public constructor (
29- sysPropKey: String ,
30- envKey: String ,
31- platform: PlatformProvider = PlatformProvider .System ,
32- @Suppress(" UNUSED_PARAMETER" ) dummy: Boolean = true ,
33- ) : this (sysPropKey as String? , envKey, platform)
26+ ) : this (" " , envKey, platform)
3427
3528 override suspend fun resolve (attributes : Attributes ): BearerToken {
36- val bearerToken = sysPropKey?.let (platform::getProperty) ? : platform.getenv(envKey)
37- if (bearerToken.isNullOrBlank()) throw IllegalStateException (""" Missing values for system property "$sysPropKey " and environment variable "$envKey """" )
29+ val bearerToken = sysPropKey.takeUnless (String ::isBlank)?.let (platform::getProperty)
30+ ? : platform.getenv(envKey)
31+ if (bearerToken.isNullOrBlank())
32+ throw IllegalStateException (""" Missing values for system property "$sysPropKey " and environment variable "$envKey """" )
3833
3934 return object : BearerToken {
4035 override val token: String = bearerToken
0 commit comments