mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 06:39:38 +07:00
IJPL-171566 Use lazy-like list via PluginClassLoader.getAllParentClassLoaders() in ClassLoaderTreeChecker for the leak check
GitOrigin-RevId: 5a0f3d61b59fee4e6158e7c742d3e5290fed1053
This commit is contained in:
committed by
intellij-monorepo-bot
parent
42b5833960
commit
32413fb37c
@@ -190,7 +190,8 @@ class PluginClassLoader(
|
||||
}
|
||||
|
||||
if (c == null) {
|
||||
for (classloader in getAllParents()) {
|
||||
@Suppress("TestOnlyProblems")
|
||||
for (classloader in getAllParentsClassLoaders()) {
|
||||
if (classloader is PluginClassLoader) {
|
||||
try {
|
||||
val consistencyError = classloader.packagePrefix?.let {
|
||||
@@ -256,7 +257,9 @@ class PluginClassLoader(
|
||||
return c
|
||||
}
|
||||
|
||||
private fun getAllParents(): Array<ClassLoader> {
|
||||
@TestOnly
|
||||
@ApiStatus.Internal
|
||||
fun getAllParentsClassLoaders(): Array<ClassLoader> {
|
||||
var result = allParents
|
||||
if (result != null && allParentsLastCacheId == parentListCacheIdCounter.get()) {
|
||||
return result
|
||||
@@ -364,7 +367,8 @@ ${if (exception == null) "" else exception.message}""")
|
||||
return null
|
||||
}
|
||||
|
||||
for (classloader in getAllParents()) {
|
||||
@Suppress("TestOnlyProblems")
|
||||
for (classloader in getAllParentsClassLoaders()) {
|
||||
if (classloader is UrlClassLoader) {
|
||||
classloader.classPath.findResource(name)?.let {
|
||||
return it.bytes
|
||||
@@ -409,7 +413,8 @@ ${if (exception == null) "" else exception.message}""")
|
||||
return f1(it)
|
||||
}
|
||||
|
||||
for (classloader in getAllParents()) {
|
||||
@Suppress("TestOnlyProblems")
|
||||
for (classloader in getAllParentsClassLoaders()) {
|
||||
if (classloader is PluginClassLoader) {
|
||||
classloader.classPath.findResource(canonicalPath)?.let {
|
||||
return f1(it)
|
||||
@@ -432,7 +437,8 @@ ${if (exception == null) "" else exception.message}""")
|
||||
override fun findResources(name: String): Enumeration<URL> {
|
||||
val resources = ArrayList<Enumeration<URL>>()
|
||||
resources.add(classPath.getResources(name))
|
||||
for (classloader in getAllParents()) {
|
||||
@Suppress("TestOnlyProblems")
|
||||
for (classloader in getAllParentsClassLoaders()) {
|
||||
if (classloader is PluginClassLoader) {
|
||||
resources.add(classloader.classPath.getResources(name))
|
||||
}
|
||||
|
||||
@@ -45,14 +45,17 @@ internal class ClassLoaderTreeChecker(private val unloadedMainDescriptor: IdeaPl
|
||||
}
|
||||
|
||||
@Suppress("TestOnlyProblems")
|
||||
val parents = classLoader._getParents()
|
||||
// use exactly getAllParentsClassLoaders because it's a lazy list that may be recalculated
|
||||
// wrong invalidation of allParents may lead to leaking unloaded class loaders hanging inside PluginClassLoader.allParents (IJPL-171566)
|
||||
val parents = classLoader.getAllParentsClassLoaders()
|
||||
for (unloadedClassLoader in classLoaders) {
|
||||
if (parents.any { it.pluginClassLoader === unloadedClassLoader }) {
|
||||
if (parents.any { it === unloadedClassLoader }) {
|
||||
LOG.error("$classLoader references via parents $unloadedClassLoader that must be unloaded")
|
||||
}
|
||||
}
|
||||
|
||||
for (parent in parents) {
|
||||
@Suppress("TestOnlyProblems")
|
||||
for (parent in classLoader._getParents()) {
|
||||
if (parent.pluginId == unloadedMainDescriptor.pluginId) {
|
||||
LOG.error("$classLoader references via parents $parent that must be unloaded")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user