Skip to content

Commit

Permalink
Backport "Fix cache service for resolution anchors"
Browse files Browse the repository at this point in the history
Use project cache correctly instead of storing values in instance fields
Move logger from instance field

Original commit: 59a10424e6a9be45fd25ad926957223e1b3b6744 (kotlin-ide)
  • Loading branch information
KirpichenkovPavel committed Feb 19, 2021
1 parent 434c199 commit d0e0900
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ class ResolutionAnchorCacheServiceImpl(val project: Project) :
var moduleNameToAnchorName: Map<String, String> = emptyMap()
)

private val logger = logger<ResolutionAnchorCacheServiceImpl>()

@JvmField
@Volatile
var myState: State = State()
Expand All @@ -65,14 +63,13 @@ class ResolutionAnchorCacheServiceImpl(val project: Project) :
object ResolutionAnchorMappingCacheKey
object ResolutionAnchorDependenciesCacheKey

override val resolutionAnchorsForLibraries: Map<LibraryInfo, ModuleSourceInfo> by lazy {
project.cacheByClassInvalidatingOnRootModifications(ResolutionAnchorMappingCacheKey::class.java) {
override val resolutionAnchorsForLibraries: Map<LibraryInfo, ModuleSourceInfo>
get() = project.cacheByClassInvalidatingOnRootModifications(ResolutionAnchorMappingCacheKey::class.java) {
mapResolutionAnchorForLibraries()
}
}

private val resolutionAnchorDependenciesCache: MutableMap<LibraryInfo, Set<ModuleSourceInfo>> =
project.cacheByClassInvalidatingOnRootModifications(ResolutionAnchorDependenciesCacheKey::class.java) {
private val resolutionAnchorDependenciesCache: MutableMap<LibraryInfo, Set<ModuleSourceInfo>>
get() = project.cacheByClassInvalidatingOnRootModifications(ResolutionAnchorDependenciesCacheKey::class.java) {
ContainerUtil.createConcurrentWeakMap()
}

Expand Down Expand Up @@ -118,4 +115,8 @@ class ResolutionAnchorCacheServiceImpl(val project: Project) :
library to anchor
}.toMap()
}

companion object {
private val logger = logger<ResolutionAnchorCacheServiceImpl>()
}
}

0 comments on commit d0e0900

Please sign in to comment.