Skip to content

Commit e9ec983

Browse files
authored
Merge pull request #368 from modelix/bugfix/version-change-detector
fix(model-client): memory leak in VersionChangeDetector
2 parents b15ba97 + 29b43c9 commit e9ec983

File tree

4 files changed

+4
-2
lines changed

4 files changed

+4
-2
lines changed

model-client/src/jvmMain/kotlin/org/modelix/model/client/RestWebModelClient.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ class RestWebModelClient @JvmOverloads constructor(
371371
return runBlocking { getA(key) }
372372
}
373373

374-
suspend fun getA(key: String): String? {
374+
override suspend fun getA(key: String): String? {
375375
val isHash = HashUtil.isSha256(key)
376376
if (isHash) {
377377
if (LOG.isDebugEnabled) {

model-client/src/jvmMain/kotlin/org/modelix/model/client/VersionChangeDetector.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ abstract class VersionChangeDetector(
6969
store.listen(key, keyListener)
7070
while (isActive) {
7171
try {
72-
val version = store[key]
72+
val version = store.getA(key)
7373
if (version != lastVersionHash) {
7474
LOG.debug { "New version detected by polling: $version" }
7575
versionChanged(version)

model-datastructure/src/commonMain/kotlin/org/modelix/model/IKeyValueStore.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package org.modelix.model
1717

1818
interface IKeyValueStore {
1919
operator fun get(key: String): String?
20+
suspend fun getA(key: String): String? = get(key)
2021
fun put(key: String, value: String?)
2122
fun getAll(keys: Iterable<String>): Map<String, String?>
2223
fun putAll(entries: Map<String, String?>)

model-server/src/main/kotlin/org/modelix/model/server/handlers/RepositoriesManager.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ class RepositoriesManager(val client: LocalModelClient) {
165165
mergedVersion.hash
166166
}
167167
putVersionHash(branch, mergedHash)
168+
ensureRepositoriesAreInList(setOf(branch.repositoryId))
168169
ensureBranchesAreInList(branch.repositoryId, setOf(branch.branchName))
169170
result = mergedHash
170171
}

0 commit comments

Comments
 (0)