Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue
import software.aws.toolkits.core.utils.createParentDirectories
import software.aws.toolkits.core.utils.debug
import software.aws.toolkits.core.utils.deleteIfExists
import software.aws.toolkits.core.utils.getLogger
import software.aws.toolkits.core.utils.inputStreamIfExists
Expand All @@ -32,7 +31,6 @@
import software.aws.toolkits.core.utils.tryDirOp
import software.aws.toolkits.core.utils.tryFileOp
import software.aws.toolkits.core.utils.tryOrNull
import software.aws.toolkits.core.utils.warn
import software.aws.toolkits.telemetry.AuthTelemetry
import software.aws.toolkits.telemetry.Result
import java.io.InputStream
Expand Down Expand Up @@ -97,16 +95,16 @@
}

override fun invalidateClientRegistration(ssoRegion: String) {
LOG.debug { "invalidateClientRegistration for $ssoRegion" }
LOG.info("invalidateClientRegistration for $ssoRegion")

Check notice on line 98 in plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/credentials/sso/DiskCache.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Non-distinguishable logging calls

Similar log messages
clientRegistrationCache(ssoRegion).tryDeleteIfExists()
}

override fun loadClientRegistration(cacheKey: ClientRegistrationCacheKey): ClientRegistration? {
LOG.debug { "loadClientRegistration for $cacheKey" }
LOG.info("loadClientRegistration for $cacheKey")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remember lazy log

val inputStream = clientRegistrationCache(cacheKey).tryInputStreamIfExists()
if (inputStream == null) {
val stage = LoadCredentialStage.ACCESS_FILE
LOG.warn { "Failed to load Client Registration: cache file does not exist" }
LOG.info("Failed to load Client Registration: cache file does not exist")
AuthTelemetry.modifyConnection(
action = "Load cache file",
source = "loadClientRegistration",
Expand All @@ -120,15 +118,15 @@
}

override fun saveClientRegistration(cacheKey: ClientRegistrationCacheKey, registration: ClientRegistration) {
LOG.debug { "saveClientRegistration for $cacheKey" }
LOG.info("saveClientRegistration for $cacheKey")
val registrationCache = clientRegistrationCache(cacheKey)
writeKey(registrationCache) {
objectMapper.writeValue(it, registration)
}
}

override fun invalidateClientRegistration(cacheKey: ClientRegistrationCacheKey) {
LOG.debug { "invalidateClientRegistration for $cacheKey" }
LOG.info("invalidateClientRegistration for $cacheKey")

Check notice on line 129 in plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/credentials/sso/DiskCache.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Non-distinguishable logging calls

Similar log messages
try {
clientRegistrationCache(cacheKey).tryDeleteIfExists()
} catch (e: Exception) {
Expand All @@ -144,7 +142,7 @@
}

override fun invalidateAccessToken(ssoUrl: String) {
LOG.debug { "invalidateAccessToken for $ssoUrl" }
LOG.info("invalidateAccessToken for $ssoUrl")

Check notice on line 145 in plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/credentials/sso/DiskCache.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Non-distinguishable logging calls

Similar log messages
try {
accessTokenCache(ssoUrl).tryDeleteIfExists()
} catch (e: Exception) {
Expand All @@ -160,7 +158,7 @@
}

override fun loadAccessToken(cacheKey: AccessTokenCacheKey): AccessToken? {
LOG.debug { "loadAccessToken for $cacheKey" }
LOG.info("loadAccessToken for $cacheKey")
val cacheFile = accessTokenCache(cacheKey)
val inputStream = cacheFile.tryInputStreamIfExists() ?: return null

Expand All @@ -170,15 +168,15 @@
}

override fun saveAccessToken(cacheKey: AccessTokenCacheKey, accessToken: AccessToken) {
LOG.debug { "saveAccessToken for $cacheKey" }
LOG.info("saveAccessToken for $cacheKey")
val accessTokenCache = accessTokenCache(cacheKey)
writeKey(accessTokenCache) {
objectMapper.writeValue(it, accessToken)
}
}

override fun invalidateAccessToken(cacheKey: AccessTokenCacheKey) {
LOG.debug { "invalidateAccessToken for $cacheKey" }
LOG.info("invalidateAccessToken for $cacheKey")

Check notice on line 179 in plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/credentials/sso/DiskCache.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Non-distinguishable logging calls

Similar log messages
try {
accessTokenCache(cacheKey).tryDeleteIfExists()
} catch (e: Exception) {
Expand All @@ -203,7 +201,7 @@
val sha = sha1(cacheNameMapper.writeValueAsString(it))

cacheDir.resolve("$sha.json").also {
LOG.debug { "$cacheKey resolves to $it" }
LOG.info("$cacheKey resolves to $it")

Check notice on line 204 in plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/credentials/sso/DiskCache.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Nested lambda has shadowed implicit parameter

Implicit parameter 'it' of enclosing lambda is shadowed
}
}

Expand All @@ -225,7 +223,7 @@
if (clientRegistration.expiresAt.isNotExpired()) {
return clientRegistration
} else {
LOG.warn { "Client Registration is expired" }
LOG.info("Client Registration is expired")
AuthTelemetry.modifyConnection(
action = "Validate Credentials",
source = "loadClientRegistration",
Expand All @@ -236,7 +234,7 @@
return null
}
} catch (e: Exception) {
LOG.warn { "Client Registration could not be read" }
LOG.info("Client Registration could not be read")
AuthTelemetry.modifyConnection(
action = "Validate Credentials",
source = "loadClientRegistration",
Expand Down Expand Up @@ -269,7 +267,7 @@
}

private fun writeKey(path: Path, consumer: (OutputStream) -> Unit) {
LOG.debug { "writing to $path" }
LOG.info("writing to $path")
try {
path.tryDirOp(LOG) { createParentDirectories() }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ class SsoAccessTokenProvider(
requestId = requestId,
result = Result.Failed
)
LOG.warn { "RefreshAccessTokenFailed: ${e.message}" }
LOG.info("RefreshAccessTokenFailed: ${e.message}")
throw e
}
}
Expand Down
Loading