New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't instantiate proxy for class kotlin.Function2 - similar class definition #997
Comments
I am receiving the same This started happening after bumping to version For our use case, we are simply mocking a kotlin interface for a test. private var testDetails: Details? = null
private val billingInventory: IBillingInventory = mockk {
every { getDetails() } answers { testDetails }
} which causes
Other instances involve mockking a java class that's provided via Dagger/Hilt which causes the same exception above. The main source I can find that could have possibly caused this was this recent change added in Can anyone shed some light on why the exception is thrown? |
We are seeing something similar. We upgraded from 1.12.2 to 1.13.4. We started seeing flakiness in tests due to the WeakReference. It's likely that there is a GC before the reference is attached to anything. package com.test
import io.mockk.proxy.common.CancelableResult
import org.junit.jupiter.api.Test
class MockkTest {
data class Payload(val something: String)
@Test
fun testing() {
val result = CancelableResult(Payload("hello world"))
System.gc()
print(result.get())
}
} Result:
|
Created a PR with a fix for handling GCs but removing the WeakReference from ProxyMaker: #1052 |
Issue #997 - Simulate garbage collected proxy
Hello I came here looking for some answers related to the I noticed that the PR was merged two days ago. Do we have visibility of when the new release will come? Thank you in advance |
Just released 1.13.5! |
I still get |
This seems to have undid the fix from #1013, now I still have memory leaks since GC can't collect the spy objects when they're cleared. |
We also have increased flakyness in our tests after updating to JDK17 and Mockk Android 1.13.4. We got the following issues very frequently: Would like to add, that the only other change we have done is using the JVM parallel garbage collector as mentioned in an Android Documentation: We also disabled that for now. Can this be related? |
May I ask if this
... issue fixed in |
@JooHyukKim Yes this is fixed in 1.13.5 |
@ygaller Thank you for letting me know! 👍🏼 |
JDK 19
Quarkus 2.14.3.Final
Mockk 1.13.3
JUnit 5.9.1
I'm trying to replace an existing instance with mock:
typealias BroadcastSwitchActiveComputer = suspend (Computer) -> Either<BroadcastSwitchActiveComputerError, Unit>
kotlin.jvm.functions.Function2<? super Computer, ? super kotlin.coroutines.Continuation<? super arrow.core.Either<? extends BroadcastSwitchActiveComputerError, ? extends kotlin.Unit>>, ?>
I have several beans with similar Function2 class definition. However they have different Either's generic type.
A full stack trace:
The text was updated successfully, but these errors were encountered: