mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-240352 MLFeaturesUtil.classNameSafeCache leaks references to plugin classes after plugin unload
GitOrigin-RevId: 25ccba01ad0139e645ec079fe85044cfce345b5a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d11bda75f7
commit
5454ca8928
@@ -1,11 +1,11 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.completion.ml
|
||||
|
||||
import com.google.common.cache.Cache
|
||||
import com.google.common.cache.CacheBuilder
|
||||
import com.intellij.codeInsight.completion.CompletionLocation
|
||||
import com.intellij.codeInsight.completion.CompletionService
|
||||
import com.intellij.codeInsight.completion.CompletionSorter
|
||||
import com.google.common.cache.CacheBuilder
|
||||
import com.google.common.cache.CacheLoader
|
||||
import com.intellij.codeInsight.completion.ml.MLFeatureValue
|
||||
import com.intellij.codeInsight.lookup.LookupElement
|
||||
import com.intellij.codeInsight.lookup.LookupElementWeigher
|
||||
@@ -31,17 +31,14 @@ object MLFeaturesUtil {
|
||||
|
||||
private val THIRD_PARTY_NAME = ClassNames("third.party", "third.party")
|
||||
|
||||
private val classNameSafeCache = CacheBuilder
|
||||
private val CLASS_NAMES_CACHE: Cache<String, ClassNames> = CacheBuilder
|
||||
.newBuilder()
|
||||
.softValues()
|
||||
.maximumSize(100)
|
||||
.build(object : CacheLoader<Class<*>, ClassNames>() {
|
||||
override fun load(clazz: Class<*>) = if (getPluginInfo(clazz).isSafeToReport()) clazz.getNames() else THIRD_PARTY_NAME
|
||||
})
|
||||
.build()
|
||||
|
||||
private fun getClassNameSafe(feature: MLFeatureValue.ClassNameValue): String {
|
||||
val clazz = feature.value
|
||||
val names = classNameSafeCache[clazz]
|
||||
val names = CLASS_NAMES_CACHE.get(clazz.name) { if (getPluginInfo(clazz).isSafeToReport()) clazz.getNames() else THIRD_PARTY_NAME }
|
||||
return if (feature.useSimpleName) names.simpleName else names.fullName
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user