Skip to content

Commit 7f8beed

Browse files
Use custom by lazy in SpringApplicationContext because of RD (#2405)
1 parent 63bd444 commit 7f8beed

File tree

1 file changed

+13
-3
lines changed
  • utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api

1 file changed

+13
-3
lines changed

utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api/Api.kt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,6 +1461,7 @@ class SpringApplicationContext(
14611461
}
14621462

14631463
private var areInjectedClassesInitialized : Boolean = false
1464+
private var areAllInjectedTypesInitialized: Boolean = false
14641465

14651466
// Classes representing concrete types that are actually used in Spring application
14661467
private val springInjectedClasses: Set<ClassId>
@@ -1493,9 +1494,18 @@ class SpringApplicationContext(
14931494
return springInjectedClassesStorage
14941495
}
14951496

1496-
private val allInjectedTypes: Set<ClassId> by lazy {
1497-
springInjectedClasses.flatMap { it.allSuperTypes() }.toSet()
1498-
}
1497+
private val allInjectedTypes: Set<ClassId>
1498+
get() {
1499+
if (!areAllInjectedTypesInitialized) {
1500+
allInjectedTypesStorage = springInjectedClasses.flatMap { it.allSuperTypes() }.toSet()
1501+
areAllInjectedTypesInitialized = true
1502+
}
1503+
1504+
return allInjectedTypesStorage
1505+
}
1506+
1507+
// imitates `by lazy` (we can't use actual `by lazy` because communication via RD breaks it)
1508+
private var allInjectedTypesStorage: Set<ClassId> = emptySet()
14991509

15001510
// This is a service field to model the lazy behavior of [springInjectedClasses].
15011511
// Do not call it outside the getter.

0 commit comments

Comments
 (0)