From ed9bd6deda0ed91a6cf91e3395895fecc7282746 Mon Sep 17 00:00:00 2001 From: slisson Date: Thu, 12 Dec 2024 15:18:17 +0100 Subject: [PATCH] fix(model-server): IImmutableStore is supposed to return null values --- .../org/modelix/model/server/store/IImmutableStore.kt | 2 +- .../org/modelix/model/server/store/IgniteStoreClient.kt | 8 ++------ .../modelix/model/server/store/InMemoryStoreClient.kt | 9 ++------- .../org/modelix/model/server/store/StoreClientAdapter.kt | 2 +- 4 files changed, 6 insertions(+), 15 deletions(-) diff --git a/model-server/src/main/kotlin/org/modelix/model/server/store/IImmutableStore.kt b/model-server/src/main/kotlin/org/modelix/model/server/store/IImmutableStore.kt index ac21f13fa9..220ce1ea6e 100644 --- a/model-server/src/main/kotlin/org/modelix/model/server/store/IImmutableStore.kt +++ b/model-server/src/main/kotlin/org/modelix/model/server/store/IImmutableStore.kt @@ -7,7 +7,7 @@ import org.modelix.model.IGenericKeyListener * Doesn't require transactions. */ interface IImmutableStore { - fun getAll(keys: Set): Map + fun getAll(keys: Set): Map fun addAll(entries: Map) fun getIfCached(key: KeyT): String? } diff --git a/model-server/src/main/kotlin/org/modelix/model/server/store/IgniteStoreClient.kt b/model-server/src/main/kotlin/org/modelix/model/server/store/IgniteStoreClient.kt index d140ec47de..2769775120 100644 --- a/model-server/src/main/kotlin/org/modelix/model/server/store/IgniteStoreClient.kt +++ b/model-server/src/main/kotlin/org/modelix/model/server/store/IgniteStoreClient.kt @@ -247,13 +247,9 @@ class IgniteStoreClient(jdbcProperties: Properties? = null, private val inmemory override fun getImmutableStore(): IImmutableStore { return object : IImmutableStore { - override fun getAll(keys: Set): Map { + override fun getAll(keys: Set): Map { keys.forEach { require(HashUtil.isSha256(it.key)) { "Not an immutable object: $it" } } - return cache.getAll(keys).mapValues { - val value = it.value - if (value == null) throw ObjectValueNotFoundException(it.key.key) - value - } + return cache.getAll(keys) } override fun addAll(entries: Map) { diff --git a/model-server/src/main/kotlin/org/modelix/model/server/store/InMemoryStoreClient.kt b/model-server/src/main/kotlin/org/modelix/model/server/store/InMemoryStoreClient.kt index bcb1520bc8..673f7892f9 100644 --- a/model-server/src/main/kotlin/org/modelix/model/server/store/InMemoryStoreClient.kt +++ b/model-server/src/main/kotlin/org/modelix/model/server/store/InMemoryStoreClient.kt @@ -2,7 +2,6 @@ package org.modelix.model.server.store import org.modelix.model.IGenericKeyListener import org.modelix.model.persistent.HashUtil -import org.modelix.model.server.handlers.ObjectValueNotFoundException import org.slf4j.LoggerFactory fun generateId(idStr: String?): Long { @@ -138,14 +137,10 @@ class InMemoryStoreClient : IsolatingStore, ITransactionManager, IRepositoryAwar override fun getImmutableStore(): IImmutableStore { return object : IImmutableStore { - override fun getAll(keys: Set): Map { + override fun getAll(keys: Set): Map { keys.forEach { require(HashUtil.isSha256(it.key)) { "Not an immutable object: $it" } } @OptIn(RequiresTransaction::class) - return runRead { this@InMemoryStoreClient.getAll(keys) }.mapValues { - val value = it.value - if (value == null) throw ObjectValueNotFoundException(it.key.key) - value - } + return runRead { this@InMemoryStoreClient.getAll(keys) } } override fun addAll(entries: Map) { diff --git a/model-server/src/main/kotlin/org/modelix/model/server/store/StoreClientAdapter.kt b/model-server/src/main/kotlin/org/modelix/model/server/store/StoreClientAdapter.kt index 4e358e6a47..9b0cba96c0 100644 --- a/model-server/src/main/kotlin/org/modelix/model/server/store/StoreClientAdapter.kt +++ b/model-server/src/main/kotlin/org/modelix/model/server/store/StoreClientAdapter.kt @@ -90,7 +90,7 @@ abstract class StoreClientAdapter(val client: IsolatingStore) : IStoreClient { override fun getImmutableStore(): IImmutableStore { val immutableStore = client.getImmutableStore() return object : IImmutableStore { - override fun getAll(keys: Set): Map { + override fun getAll(keys: Set): Map { val fromRepository = immutableStore.getAll(keys.map { it.withRepoScope() }.toSet()).mapKeys { it.key.key } if (getRepositoryId() == null) return fromRepository