aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorPaweł Marks <pmarks@virtuslab.com>2020-07-06 10:18:39 +0200
committerSebastian Sellmair <34319766+sellmair@users.noreply.github.com>2020-07-07 13:22:16 +0200
commite5360a5b26aaaf779e796c16b6ac1bd625d2d02a (patch)
tree2cc51bb67268023d77d7876ca3c1c4c31b7c15a5 /plugins
parentdb2fb23257cb7ea34f9b359a0525abcf76641d8e (diff)
downloaddokka-e5360a5b26aaaf779e796c16b6ac1bd625d2d02a.tar.gz
dokka-e5360a5b26aaaf779e796c16b6ac1bd625d2d02a.tar.bz2
dokka-e5360a5b26aaaf779e796c16b6ac1bd625d2d02a.zip
Fix racecondition on caching of external providers
Diffstat (limited to 'plugins')
-rw-r--r--plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProviderFactory.kt5
1 files changed, 3 insertions, 2 deletions
diff --git a/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProviderFactory.kt b/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProviderFactory.kt
index 6fb05024..ce6fbba0 100644
--- a/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProviderFactory.kt
+++ b/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProviderFactory.kt
@@ -1,6 +1,7 @@
package org.jetbrains.dokka.base.resolvers.external
import org.jetbrains.dokka.links.DRI
+import java.util.concurrent.ConcurrentHashMap
interface ExternalLocationProvider {
@@ -16,8 +17,8 @@ interface ExternalLocationProviderFactory {
class ExternalLocationProviderFactoryWithCache(val ext: ExternalLocationProviderFactory) : ExternalLocationProviderFactory {
- private val locationProviders: MutableList<ExternalLocationProvider> = mutableListOf()
+ private val locationProviders = ConcurrentHashMap<String, ExternalLocationProvider>()
override fun getExternalLocationProvider(param: String): ExternalLocationProvider? =
- locationProviders.find { it.param == param } ?: ext.getExternalLocationProvider(param)?.also { locationProviders.add(it) }
+ locationProviders.getOrPut(param) { ext.getExternalLocationProvider(param) }
} \ No newline at end of file