Skip to content

Commit 1200d30

Browse files
committed
ISSUE-647: Restore interceptors on exception in flaky safety (#741)
* ISSUE-647: Restore interceptors on exception in flaky safety (cherry picked from commit c473873)
1 parent 6ae44b7 commit 1200d30

1 file changed

Lines changed: 19 additions & 11 deletions

File tree

kaspresso/src/main/kotlin/com/kaspersky/kaspresso/flakysafety/FlakySafetyProviderGlobalImpl.kt

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,15 @@ class FlakySafetyProviderGlobalImpl(
5858
override fun <T> flakySafely(action: () -> T): T {
5959
flakySafeInterceptorScalpel.scalpFromLibs()
6060

61-
val result = flakySafetyAlgorithm.invokeFlakySafely(
62-
params = getParams(),
63-
action = action
64-
)
65-
61+
val result = try {
62+
flakySafetyAlgorithm.invokeFlakySafely(
63+
params = getParams(),
64+
action = action
65+
)
66+
} catch (ex: Throwable) {
67+
flakySafeInterceptorScalpel.restoreScalpToLibs()
68+
throw ex
69+
}
6670
flakySafeInterceptorScalpel.restoreScalpToLibs()
6771

6872
return result
@@ -91,12 +95,16 @@ class FlakySafetyProviderGlobalImpl(
9195
): T {
9296
flakySafeInterceptorScalpel.scalpFromLibs()
9397

94-
val result = flakySafetyAlgorithm.invokeFlakySafely(
95-
params = getParams(timeoutMs, intervalMs, allowedExceptions),
96-
failureMessage = failureMessage,
97-
action = action
98-
)
99-
98+
val result = try {
99+
flakySafetyAlgorithm.invokeFlakySafely(
100+
params = getParams(timeoutMs, intervalMs, allowedExceptions),
101+
failureMessage = failureMessage,
102+
action = action
103+
)
104+
} catch (ex: Throwable) {
105+
flakySafeInterceptorScalpel.restoreScalpToLibs()
106+
throw ex
107+
}
100108
flakySafeInterceptorScalpel.restoreScalpToLibs()
101109

102110
return result

0 commit comments

Comments
 (0)