autoClose breaks Lazy #2388
Labels
bug 🐛
Issues that report a problem or error in the code.
framework 🏗️
Pertains to the core structure and components of the Kotest framework.
Milestone
Which version of Kotest are you using
1.4.6
Here Lazy is immediately invoked which initializes the Lazy value, to then pass it to the immediate autoClose function which rewraps in Lazy here.
If delegation happens to other way around, meaning
fun <T : AutoCloseable> autoClose(closeable: T): T
usesfun <T : AutoCloseable> autoClose(closeable: Lazy<T>): Lazy<T>
than Lazy'ness can be preserved.When closing the
AutoCloseable
ininvokeAfterSpec
you can checkLazy#isInitialised
before callinglazy.value.close()
to avoid initializing values that are not used, and thus don't need to be closed.The text was updated successfully, but these errors were encountered: