Skip to content

Commit

Permalink
Merge pull request #368 from modelix/bugfix/version-change-detector
Browse files Browse the repository at this point in the history
fix(model-client): memory leak in VersionChangeDetector
  • Loading branch information
slisson authored Dec 9, 2023
2 parents b15ba97 + 29b43c9 commit e9ec983
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ class RestWebModelClient @JvmOverloads constructor(
return runBlocking { getA(key) }
}

suspend fun getA(key: String): String? {
override suspend fun getA(key: String): String? {
val isHash = HashUtil.isSha256(key)
if (isHash) {
if (LOG.isDebugEnabled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ abstract class VersionChangeDetector(
store.listen(key, keyListener)
while (isActive) {
try {
val version = store[key]
val version = store.getA(key)
if (version != lastVersionHash) {
LOG.debug { "New version detected by polling: $version" }
versionChanged(version)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package org.modelix.model

interface IKeyValueStore {
operator fun get(key: String): String?
suspend fun getA(key: String): String? = get(key)
fun put(key: String, value: String?)
fun getAll(keys: Iterable<String>): Map<String, String?>
fun putAll(entries: Map<String, String?>)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ class RepositoriesManager(val client: LocalModelClient) {
mergedVersion.hash
}
putVersionHash(branch, mergedHash)
ensureRepositoriesAreInList(setOf(branch.repositoryId))
ensureBranchesAreInList(branch.repositoryId, setOf(branch.branchName))
result = mergedHash
}
Expand Down

0 comments on commit e9ec983

Please sign in to comment.