Skip to content

Commit

Permalink
fix(expressions): Fix ConcurrentModificationException (#2698)
Browse files Browse the repository at this point in the history
Fixes error introduced by me in #2653
  • Loading branch information
marchello2000 authored and emjburns committed Mar 5, 2019
1 parent 36ae8ce commit 54a26d0
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,19 @@ interface ExpressionAware {
// context. Otherwise, it's very confusing in the UI because the value is clearly correctly evaluated but
// the error is still shown
if (hasFailedExpressions()) {
val failedExpressions = this.context[PipelineExpressionEvaluator.SUMMARY] as MutableMap<String, *>
try {
val failedExpressions = this.context[PipelineExpressionEvaluator.SUMMARY] as MutableMap<String, *>

failedExpressions.keys.forEach { expressionKey ->
if (evalSummary.wasAttempted(expressionKey) && !evalSummary.hasFailed(expressionKey)) {
val keysToRemove: List<String> = failedExpressions.keys.filter { expressionKey ->
(evalSummary.wasAttempted(expressionKey) && !evalSummary.hasFailed(expressionKey))
}.toList()

keysToRemove.forEach { expressionKey ->
failedExpressions.remove(expressionKey)
}
} catch (e: Exception) {
// Best effort clean up, if if fails just log the error and leave the context be
log.error("Failed to remove stale expression errors", e)
}
}

Expand Down

0 comments on commit 54a26d0

Please sign in to comment.