Skip to content

Commit 668a31e

Browse files
committed
fix(model-datastructure): catch exceptions in checkRoleId
1 parent 26b4451 commit 668a31e

File tree

1 file changed

+5
-3
lines changed
  • model-datastructure/src/commonMain/kotlin/org/modelix/model/lazy

1 file changed

+5
-3
lines changed

model-datastructure/src/commonMain/kotlin/org/modelix/model/lazy/CLTree.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class CLTree : ITree, IBulkTree {
4848
constructor(hash: String?, store: IDeserializingKeyValueStore) : this(if (hash == null) null else store.get<CPTree>(hash) { CPTree.deserialize(it) }, store)
4949
constructor(store: IDeserializingKeyValueStore) : this(null as CPTree?, store)
5050
constructor(data: CPTree?, store_: IDeserializingKeyValueStore) : this(data, null as RepositoryId?, store_)
51-
private constructor(data: CPTree?, repositoryId_: RepositoryId?, store_: IDeserializingKeyValueStore, useRoleIds: Boolean = false) {
51+
constructor(data: CPTree?, repositoryId_: RepositoryId?, store_: IDeserializingKeyValueStore, useRoleIds: Boolean = false) {
5252
var repositoryId = repositoryId_
5353
var store = store_
5454
if (data == null) {
@@ -580,8 +580,10 @@ class CLTree : ITree, IBulkTree {
580580
private fun checkPropertyRoleId(nodeId: Long, role: String?) = checkRoleId(nodeId, role) { it.getAllProperties() }
581581
private fun checkRoleId(nodeId: Long, role: String?, rolesGetter: (IConcept) -> Iterable<IRole>) {
582582
if (role != null && usesRoleIds()) {
583-
val concept = getConceptReference(nodeId)?.tryResolve()
584-
if (concept != null && rolesGetter(concept).any { it.getSimpleName() == role }) {
583+
val isKnownRoleName = getConceptReference(nodeId)?.tryResolve()?.let { concept ->
584+
runCatching { rolesGetter(concept).any { it.getSimpleName() == role } }.getOrNull()
585+
} ?: false
586+
if (isKnownRoleName) {
585587
throw IllegalArgumentException("A role UID is expected, but a name was provided: $role")
586588
}
587589
}

0 commit comments

Comments
 (0)