Skip to content

Commit

Permalink
fix retry ignore subclass of exception class
Browse files Browse the repository at this point in the history
  • Loading branch information
kin4496 committed Mar 29, 2024
1 parent 2d62856 commit 3e22202
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ class RetryTest : StringSpec() {

testClass.times shouldBe 1
}

"should retry in case of subclass exception"{
val testClass = TestClass(3)
runSafely {
retry(2, 500.milliseconds, 20.milliseconds, 1, Exception::class) {
testClass.throwUnexpectedException()
}
}
testClass.times shouldBe 2
}
}

private class TestClass(private val readyAfter: Int) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ suspend fun <T> retry(
when {
// Not the kind of exceptions we were prepared to tolerate
e::class.simpleName != "AssertionError" &&
e::class != config.exceptionClass &&
config.exceptionClass?.isInstance(e) == false &&
e::class.bestName() != "org.opentest4j.AssertionFailedError" &&
!e::class.bestName().endsWith("AssertionFailedError") -> throw e
}
Expand Down

0 comments on commit 3e22202

Please sign in to comment.