kosi-libs/MocKMP

Getting NullPointerExceptions

benkuly opened this issue · 7 comments

We have a bunch of tests flickering because sometimes MocKMP throws a NullPointerException:

java.lang.NullPointerException
	at org.kodein.mock.Mocker.process(Mocker.kt:76)
	at org.kodein.mock.Mocker.registerSuspend(Mocker.kt:309)
	at org.kodein.mock.Mocker.registerSuspend$default(Mocker.kt:148)

We need more information to address this.

  • Which version of MocKMP are you using ?
  • Are you using an obfuscator / optimizer such as proguard or R8 ?
  • Can you provide the full stack trace ?
  • Can you provide a reproducer ?
  • Version 1.10.0
  • No obfuscator / optimizer
  • more info to follow as soon as we observe it again

Are you using !! in MockKMP? I think this should be replaced with requreNotNull(value){"reason"} or save navigation ?. to avoid NullPointerExceptions, which are really hard to debug.

We really need a reproducer for this.

I know. Our CI did not run much the last month to see the issue again. It is not reliably reproducible, only happens every few times. I remember, that when I tried to debug it the last time it came from a part of MockKMP where !! is used.

Just wanted to inform you, that the issue still appears randomly. Unfortunately in a non-public project.

java.lang.NullPointerException
	at org.kodein.mock.Mocker.process(Mocker.kt:76)
	at org.kodein.mock.Mocker.registerSuspend(Mocker.kt:309)
	at org.kodein.mock.Mocker.registerSuspend$default(Mocker.kt:148)
	...
	at org.kodein.mock.Mocker.verifyWithSuspend(Mocker.kt:234)
	at org.kodein.mock.Mocker.verifyWithSuspend$default(Mocker.kt:233)

I've removed all !! in version 1.12.0 and replaced them either with safe access (which should fix this issue) or with more semantic exceptions (which will not fix this issue, but provide a more semantic stack trace).
I'll close this in the hope that the situation is the former.
If it is the later, please re-open this issue.

Thank you very much :)