Skip to content

Split dependency and plugin resolver caches - #1578

Open
Ivan Chirkov (chrkv) wants to merge 3 commits into
masterfrom
split-dependency-and-plugin-resolver-caches
Open

Split dependency and plugin resolver caches#1578
Ivan Chirkov (chrkv) wants to merge 3 commits into
masterfrom
split-dependency-and-plugin-resolver-caches

Conversation

@chrkv

Copy link
Copy Markdown
Collaborator

Description

CachingPluginDependencyResolverProvider currently stores dependency-closure resolvers and plugin classpath resolvers in the same cache. These resolvers have different semantics: a dependency resolver contains the plugin's dependencies, while a plugin resolver contains the plugin's own classes.

Using the same cache entry for both can make resolution depend on which resolver was created first.

This change separates the two caches and makes their keys identify the actual plugin artifact by ID, version, and original path. DefaultClassResolverProvider now explicitly requests the cached plugin resolver instead of reusing the dependency resolver cache.

Added regression tests for separate dependency/plugin resolver entries, different plugin versions, and different artifacts with the same ID and version.

}

@Test
fun `dependency closure and plugin classpath resolvers use different cache entries`() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rename to transitive dependency resolver and plugin classpath resolver use different cache entries.

val ide = MockIde(ideVersion, ideRoot, bundledPlugins = listOf(betaPlugin))
val betaAction = "com/example/beta/BetaAction"

val dependencyClosureFirst = CachingPluginDependencyResolverProvider(ide)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

val transitiveDependenciesFirst?

}

@Test
fun `dependency closure cache distinguishes plugin versions`() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto, do not introduce "dependency closure", as it is not used anywhere, terminology-wise

}

@Test
fun `dependency closure cache distinguishes artifacts with same id and version`() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto "dependency closure"

return this as? NamedResolver ?: CompositeResolver.create(listOf(this), fallbackName)
}

private fun IdePlugin.artifactKey(): PluginArtifactKey =

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider intern()in this?

private fun IdePlugin.artifactKey(): PluginArtifactKey =
PluginArtifactKey(id ?: UNNAMED_RESOLVER, pluginVersion, originalFile)

private fun IdePlugin.resolverCacheKey(resolverName: String = newResolverName()): PluginResolverKey =

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto interning?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants