Fix non-deterministic AssertionError when using MockMakers.SUBCLASS (#3406, #2823) - #3795
Merged
Merged
Conversation
Member
|
Good catch, thanks. |
Contributor
Author
|
The bug that was fixed with this PR unfortunately currently blocks update from Mockito 4 to Mockito 5 in our project. The last Mockito version |
Collaborator
|
Thanks for the reminder - we should cut a new release. I'll do that shortly. |
This was referenced Sep 26, 2026
dongjoon-hyun
added a commit
to apache/spark-kubernetes-operator
that referenced
this pull request
Sep 29, 2026
### What changes were proposed in this pull request? This PR aims to upgrade `Mockito` to 5.24.0. Since `mockito-core` 5.24.0 declares the same dependencies as 5.23.0 (`byte-buddy` 1.17.7, `byte-buddy-agent` 1.17.7, and `objenesis` 3.3), only the `org.mockito:mockito-core` entry of `gradle/verification-metadata.xml` is changed. ### Why are the changes needed? To bring the latest bug fixes. - https://github.com/mockito/mockito/releases/tag/v5.24.0 (2026-09-23) - Fix data race in `InvocationContainerImpl.invocationForStubbing` (mockito/mockito#3819) - Fix non-deterministic `AssertionError` when using `MockMakers.SUBCLASS` (mockito/mockito#3795) - Fix `clearInlineMocks` not de-registering singleton mocks (mockito/mockito#3829) - Preserve method parameters when clearing inline mocks (mockito/mockito#3847) ### Does this PR introduce _any_ user-facing change? No. `Mockito` is a test-only dependency. ### How was this patch tested? Pass the CIs. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Opus 5.5 Closes #903 from dongjoon-hyun/SPARK-59838. Authored-by: Dongjoon Hyun <dongjoon@apache.org> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MockUtil::mockMakersis aConcurrentHashMapwith random iteration order based on identify hash-code ofClasskeys.Depending on the order the following code in
MockUtil::getMockHandlerOrNullsometimes throwsAssertionErrorafterMockMakers.SUBCLASSwas used:Specifically the following order causes issues:
The problem was previously reported in #3406 and #2823.
Checklist
including project members to get a better picture of the change
commit is meaningful and help the people that will explore a change in 2 years
./gradlew spotlessApplyfor auto-formatting)Fixes #<issue number>in the description if relevantFixes #<issue number>if relevant