This repository was archived by the owner on Jan 20, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
src/main/kotlin/com/mapk/kmapper Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change 11package com.mapk.kmapper
22
33import com.mapk.core.EnumMapper
4+ import java.util.concurrent.ConcurrentHashMap
5+ import java.util.concurrent.ConcurrentMap
46import kotlin.reflect.KClass
57import kotlin.reflect.KFunction
68import kotlin.reflect.KParameter
@@ -13,7 +15,7 @@ internal class ParameterForMap<T : Any> private constructor(val param: KParamete
1315 // リストの長さが小さいと期待されるためこの形で実装しているが、理想的にはmap的なものが使いたい
1416 private val converters: Set <Pair <KClass <* >, KFunction <T >>> = clazz.getConverters()
1517
16- private val convertCache: MutableMap <KClass <* >, (Any ) -> Any? > = HashMap ()
18+ private val convertCache: ConcurrentMap <KClass <* >, (Any ) -> Any? > = ConcurrentHashMap ()
1719
1820 fun <U : Any > mapObject (value : U ): Any? {
1921 val valueClazz: KClass <* > = value::class
@@ -38,7 +40,7 @@ internal class ParameterForMap<T : Any> private constructor(val param: KParamete
3840 clazz == String ::class -> { { it.toString() } }
3941 else -> throw IllegalArgumentException (" Can not convert $valueClazz to $clazz " )
4042 }
41- convertCache[ valueClazz] = lambda
43+ convertCache.putIfAbsent( valueClazz, lambda)
4244 return lambda(value)
4345 }
4446
You can’t perform that action at this time.
0 commit comments