KTIJ-37664 [kotlin] Use dropSynchronously in KtCompilerPluginsProviderIdeImpl to drop pluginsCacheCachedValue

This allows the explicit disposal of `KtCompilerPluginsProviderIdeImpl`
to wait until the initialization of `pluginsCacheCachedValue` has finished.

It is not the best solution, because ideally, nobody from the outside
should call the `dispose` function directly on their own.

Unfortunately, `kotlin-rpc` plugin has to do that at the moment,
since it has to download jars with compiler plugins from the network,
and at some point should be able to present a renewed versions of bundled
jars from its `KotlinBundledFirCompilerPluginProvider` implementation.

To address that in the future, please see KTIJ-37667.

^KTIJ-37664 Fixed

GitOrigin-RevId: 867ebe0d1d8df902d1f6ecd5ec6b2cc7f5b54999
This commit is contained in:
Roman Golyshev
2026-03-12 13:39:41 +00:00
committed by intellij-monorepo-bot
parent d9c916532f
commit c25ca68770
@@ -103,9 +103,16 @@ internal class KtCompilerPluginsProviderIdeImpl(
/**
* Throws away the cache for all the registered plugins, and executes all the disposables
* registered in the corresponding [CompilerPluginRegistrar.ExtensionStorage]s.
*
* Note: we drop the [pluginsCacheCachedValue] synchronously, so that
* the [KtCompilerPluginsCache.new] call and all the calls to [KotlinBundledFirCompilerPluginProvider.provideBundledPluginJar] in it
* either have not yet started, or have already completed.
*
* Otherwise, race conditions similar to KTIJ-37664 may occur.
*/
private fun resetPluginsCache() {
pluginsCacheCachedValue.drop()?.dispose()
val cache = pluginsCacheCachedValue.dropSynchronously()
cache?.dispose()
}
companion object {