Skip to content

Commit 28c9516

Browse files
EgorkaKulikovtepa46
authored andcommitted
Fix JcContainer caching
1 parent 5e7dc27 commit 28c9516

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

utbot-junit-contest/src/main/kotlin/org/utbot/contest/usvm/ContestUsvm.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ fun runUsvmGeneration(
255255
fun createJcContainer(
256256
tmpDir: File,
257257
classpathFiles: List<File>
258-
) = JcContainer(
258+
) = JcContainer.getOrCreate(
259259
usePersistence = false,
260260
persistenceDir = tmpDir,
261261
classpath = classpathFiles,

utbot-usvm/src/main/kotlin/org/utbot/usvm/jc/JcContainer.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ import kotlin.time.Duration.Companion.seconds
1818
private val logger = KotlinLogging.logger {}
1919

2020
// TODO usvm-sbft-refactoring: copied from `usvm/usvm-jvm/test`, extract this class back to USVM project
21-
class JcContainer private constructor(
21+
/**
22+
* NOTE that JcContainer can also be instantiated with [JcContainer.getOrCreate] method.
23+
*
24+
* Calling constructor directly should be used if you definitely want to create
25+
* new JcContainer instead of trying it get it from containers cache.
26+
*/
27+
class JcContainer(
2228
usePersistence: Boolean,
2329
persistenceDir: File,
2430
classpath: List<File>,
@@ -91,7 +97,7 @@ class JcContainer private constructor(
9197

9298
private val cache = HashMap<List<File>, JcContainer>()
9399

94-
operator fun invoke(
100+
fun getOrCreate(
95101
usePersistence: Boolean,
96102
persistenceDir: File,
97103
classpath: List<File>,

0 commit comments

Comments
 (0)