Skip to content

Commit 9a7f5ec

Browse files
slissonmhuster23
authored andcommitted
chore(bulk-model-sync-lib): check if a node is already deleted to avoid exceptions
INode.remove throws an exception if the node isn't part of the model anymore, because it was implicitly deleted by deleting one of its ancestors before. Checking INode.isValid before calling INode.remove() avoids this exception.
1 parent 2d383ab commit 9a7f5ec

File tree

1 file changed

+3
-1
lines changed
  • bulk-model-sync-lib/src/commonMain/kotlin/org/modelix/model/sync/bulk

1 file changed

+3
-1
lines changed

bulk-model-sync-lib/src/commonMain/kotlin/org/modelix/model/sync/bulk/ModelImporter.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ class ModelImporter(private val root: INode, private val continueOnError: Boolea
9494
logger.info { "Removing extra nodes..." }
9595
nodesToRemove.forEach {
9696
doAndPotentiallyContinueOnErrors {
97-
it.remove()
97+
if (it.isValid) { // if it's invalid then it's already removed
98+
it.remove()
99+
}
98100
}
99101
}
100102

0 commit comments

Comments
 (0)