Open cloudshiftchris opened 1 month ago
Looking through the tests - they aren't up-to-date wrt cacheBuilder
(most use caffeineBuilder
) - the test for exception propagation works for caffeineBuilder
but fails when changed to cacheBuilder
// from unit test: https://github.com/sksamuel/aedile/blob/8d3ea128b474062dae9ad6b925f3f0c5d748a75d/aedile-core/src/test/kotlin/com/sksamuel/aedile/core/CacheTest.kt#L42
// exception propagation works
val cache = caffeineBuilder<String, String>().build()
shouldThrow<IllegalStateException> {
cache.get("foo") {
error("kapow")
}
}
// using cacheBuilder instead
// exception propagation fails - coroutine is cancelled
val cache2 = cacheBuilder<String, String>().build()
shouldThrow<IllegalStateException> {
cache2.get("foo") {
error("kapow")
}
}
Expecting
cache.get(key) { ... load value here ... }
to propagate exceptions to the caller, as documented:What happens instead is the coroutine is cancelled and a JobCancellationException is thrown.
Exception: kotlinx.coroutines.JobCancellationException: TimeoutCoroutine is cancelling; job=TimeoutCoroutine(timeMillis=45000){Cancelling}@609ac453
(this is inside a kotest test)