Skip to content

Commit

Permalink
Revert "Replace runCatching-map-getOrDefault in caching (Kotlin#2248)"
Browse files Browse the repository at this point in the history
This reverts commit da91066.
  • Loading branch information
xBaank authored Apr 20, 2023
1 parent fcb0c55 commit 538a6ef
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions core/jvmMain/src/kotlinx/serialization/internal/Caching.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@ import kotlin.reflect.KTypeProjection
* but ClassValue is not available on Android, thus we attempt to check it dynamically
* and fallback to ConcurrentHashMap-based cache.
*/
private val useClassValue = try {
private val useClassValue = runCatching {
Class.forName("java.lang.ClassValue")
true
} catch (_: Throwable) {
false
}
}.map { true }.getOrDefault(false)

/**
* Creates a **strongly referenced** cache of values associated with [Class].
Expand Down

0 comments on commit 538a6ef

Please sign in to comment.