Skip to content

Commit de1712a

Browse files
authored
Make findEqualValueOfWellKnownType catch exceptions #2554 (#2555)
1 parent 4a75abc commit de1712a

File tree

1 file changed

+8
-6
lines changed
  • utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/constructors

1 file changed

+8
-6
lines changed

utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/constructors/UtModelConstructor.kt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -348,12 +348,14 @@ class UtModelConstructor(
348348
?: constructCompositeModel(value, remainingDepth)
349349
}
350350

351-
private fun findEqualValueOfWellKnownType(value: Any): Pair<Any, ClassId>? = when (value) {
352-
is List<*> -> ArrayList(value) to listClassId
353-
is Set<*> -> LinkedHashSet(value) to setClassId
354-
is Map<*, *> -> LinkedHashMap(value) to mapClassId
355-
else -> null
356-
}
351+
private fun findEqualValueOfWellKnownType(value: Any): Pair<Any, ClassId>? = runCatching {
352+
when (value) {
353+
is List<*> -> ArrayList(value) to listClassId
354+
is Set<*> -> LinkedHashSet(value) to setClassId
355+
is Map<*, *> -> LinkedHashMap(value) to mapClassId
356+
else -> null
357+
}
358+
}.getOrNull()
357359

358360
/**
359361
* Constructs custom UtModel but does it only for predefined list of classes.

0 commit comments

Comments
 (0)