package org.jetbrains.dokka.base.resolvers.external

import org.jetbrains.dokka.links.DRI


interface ExternalLocationProvider {

    val param: String
    fun DRI.toLocation(): String
}

interface ExternalLocationProviderFactory {

    fun getExternalLocationProvider(param: String): ExternalLocationProvider?
}

class ExternalLocationProviderFactoryWithCache(val ext: ExternalLocationProviderFactory) : ExternalLocationProviderFactory {

    private val locationProviders: MutableList<ExternalLocationProvider> = mutableListOf()

    override fun getExternalLocationProvider(param: String): ExternalLocationProvider? =
        locationProviders.find { it.param == param } ?: ext.getExternalLocationProvider(param)?.also { locationProviders.add(it) }
}
package org.jetbrains.dokka.base.resolvers.external

import org.jetbrains.dokka.links.DRI
import java.util.concurrent.ConcurrentHashMap


interface ExternalLocationProvider {

    val param: String
    fun DRI.toLocation(): String
}

interface ExternalLocationProviderFactory {

    fun getExternalLocationProvider(param: String): ExternalLocationProvider?
}

class ExternalLocationProviderFactoryWithCache(val ext: ExternalLocationProviderFactory) : ExternalLocationProviderFactory {

    private val locationProviders = ConcurrentHashMap<String, ExternalLocationProvider>()

    override fun getExternalLocationProvider(param: String): ExternalLocationProvider? =
        locationProviders.getOrPut(param) { ext.getExternalLocationProvider(param) }
}
Fix racecondition on caching of external providers
Fix racecondition on caching of external providers

Kotlin/dokka,Kotlin/dokka,Kotlin/dokka,Kotlin/dokka,Kotlin/dokka,Kotlin/dokka