Closed kubukoz closed 4 months ago
I suppose the code was written back in the day of CE2, when we didn't have allocatedCase
. Also, instead of Resource.apply
we should probably be using applyFull
and wrapping the underlying resource in cancelable
Hi!
I noticed that
allocated
is used several times instead ofallocatedCase
. If I got it right, this would mean that theExitCase
that the finalizer of a resource receives will always beExitCase.Succeeded
, even if wrapped in anotherResource.apply
.The relevant spots are:
https://github.com/typelevel/natchez/blob/d1513b862d615c491a6bbb9ebfe28211513b1492/modules/mtl/shared/src/main/scala/LocalTrace.scala#L39
https://github.com/typelevel/natchez/blob/d1513b862d615c491a6bbb9ebfe28211513b1492/modules/core/shared/src/main/scala/Trace.scala#L180
(there are actually more in that file)
I believe for a correct implementation these should be replaced with the case-aware variants. Otherwise, the resources being wrapped will never be closed with a Canceled/Errored exit.