Skip to content

Commit

Permalink
Remove accidentally reverted weak reference
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonRa committed Sep 11, 2023
1 parent 31ce02d commit fc4b0c5
Showing 1 changed file with 1 addition and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import io.mockk.proxy.common.transformation.InlineInstrumentation
import io.mockk.proxy.common.transformation.TransformationRequest
import io.mockk.proxy.common.transformation.TransformationType.SIMPLE
import io.mockk.proxy.jvm.transformation.SubclassInstrumentation
import java.lang.ref.SoftReference
import java.lang.ref.WeakReference
import java.lang.reflect.Method
import java.lang.reflect.Modifier

Expand Down Expand Up @@ -48,13 +46,10 @@ internal class ProxyMaker(
val proxy = instantiate(actualClass, proxyClass, useDefaultConstructor, instance)

handlers[proxy] = handler
val callbackRef = WeakReference(proxy)
return result
.withValue(proxy)
.alsoOnCancel {
callbackRef.get()?.let {
handlers.remove(it)
}
handlers.remove(proxy)
}
} catch (e: Exception) {
result.cancel()
Expand Down

0 comments on commit fc4b0c5

Please sign in to comment.