Avoid runnig potentially unsafe code in finally{}, which can mask the original exception.

This commit is contained in:
Fedor Isakov 2016-06-24 14:21:36 +02:00
parent 2ae25c6756
commit 34dc1208f3
1 changed files with 6 additions and 5 deletions

View File

@ -58,16 +58,17 @@ class MemEvaluationSession : EvaluationSession, SessionObjects {
ourBackend.ourSession.set(session)
val durations = myParameters.get("profiling.data") as MutableMap<String, String>?
val profiler = durations?.let{ Profiler() }
val profiler = durations?.let { Profiler() }
try {
session.launch(myParameters["main"] as Constraint, profiler)
}
finally {
ourBackend.ourSession.set(null)
profiler?.run {
formattedData().entries.forEach { e -> durations?.put(e.key, e.value) }
clear()
}
}
profiler?.run {
formattedData().entries.forEach { e -> durations?.put(e.key, e.value) }
clear()
}
return session