Probably - Groovy Spock 2.4 has a bug in MockitoMockMakerImpl.asMockOrNull() — it passes null objects directly to Mockito's WeakConcurrentMap.get() without a null check #2336
Closed
yuriyslobodchikovrc
started this conversation in
General
Replies: 2 comments 4 replies
-
|
Of cause AI can hallucinate |
Beta Was this translation helpful? Give feedback.
3 replies
-
|
I can reproduce the issue. Please note that the interaction |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello!
Here is Claude Code tries to describe reason why tests are failing using combination of versions newer 2.4-M4-groovy-4.0 with mockito and groovy
may be it is wrong:
Groovy 5.x blocked by: Groovy Spock 2.4 has a bug in MockitoMockMakerImpl.asMockOrNull() — it passes null objects directly to Mockito's WeakConcurrentMap.get() without a null check, causing
NPE. The M4 milestone didn't have this MockitoMockMaker feature. .. Groovy 5 upgrade needs to wait for a
Spock patch release (2.4.1+).
" Now I see it clearly. Both M4 and stable call setInteraction() from MockInteraction constructor at offset 99, and both versions end up calling asMockOrNull. But the key difference is in
TargetConstraint.setInteraction():
required (1 * ...). For stubs (>>) it's not required, so M4 skips the whole block.
That's the root cause: stable removed the isRequired() guard, so stubs now also call asMockOrNull, which hits the MockitoMockMaker NPE on null targets.
Bottom line: M4 is the correct choice. The Spock 2.4 stable changed TargetConstraint to always query mock makers, exposing the MockitoMockMaker null-handling bug. Staying on Groovy 4.0.31 +
Spock 2.4-M4-groovy-4.0 is correct. "
Beta Was this translation helpful? Give feedback.
All reactions