diff options
author | Paweł Marks <pmarks@virtuslab.com> | 2020-07-06 16:46:28 +0200 |
---|---|---|
committer | Sebastian Sellmair <34319766+sellmair@users.noreply.github.com> | 2020-07-07 13:22:16 +0200 |
commit | 2da1f3b1612fd19be8082283c6d070759a42de12 (patch) | |
tree | db5719acd6552fa6e69d01fc627c9daa4962e594 /plugins/base/src/main/kotlin/resolvers | |
parent | e5360a5b26aaaf779e796c16b6ac1bd625d2d02a (diff) | |
download | dokka-2da1f3b1612fd19be8082283c6d070759a42de12.tar.gz dokka-2da1f3b1612fd19be8082283c6d070759a42de12.tar.bz2 dokka-2da1f3b1612fd19be8082283c6d070759a42de12.zip |
Add CacheWrapper to mitigate NPE issues
Diffstat (limited to 'plugins/base/src/main/kotlin/resolvers')
-rw-r--r-- | plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProviderFactory.kt | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProviderFactory.kt b/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProviderFactory.kt index ce6fbba0..83de9911 100644 --- a/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProviderFactory.kt +++ b/plugins/base/src/main/kotlin/resolvers/external/ExternalLocationProviderFactory.kt @@ -17,8 +17,10 @@ interface ExternalLocationProviderFactory { class ExternalLocationProviderFactoryWithCache(val ext: ExternalLocationProviderFactory) : ExternalLocationProviderFactory { - private val locationProviders = ConcurrentHashMap<String, ExternalLocationProvider>() + private val locationProviders = ConcurrentHashMap<String, CacheWrapper>() override fun getExternalLocationProvider(param: String): ExternalLocationProvider? = - locationProviders.getOrPut(param) { ext.getExternalLocationProvider(param) } -}
\ No newline at end of file + locationProviders.getOrPut(param) { CacheWrapper(ext.getExternalLocationProvider(param)) }.provider +} + +private class CacheWrapper(val provider: ExternalLocationProvider?)
\ No newline at end of file |