Fix clearInlineMocks not de-registering singleton mocks - #3829
Merged
jselbo merged 2 commits intoMay 29, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3829 +/- ##
=========================================
Coverage 86.84% 86.84%
Complexity 3042 3042
=========================================
Files 343 343
Lines 9174 9175 +1
Branches 1136 1136
=========================================
+ Hits 7967 7968 +1
Misses 917 917
Partials 290 290 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
jselbo
reviewed
May 29, 2026
Collaborator
|
Also I am curious, are you using the new |
Contributor
Author
Actually, I was curious about your last commit (af081a3), so I started looking into it and found the discrepancy in the clearMock. Then AI highlighted the other discrepancy 😅 |
jselbo
approved these changes
May 29, 2026
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.
Description
Problem: singleton mocks were leaking since clearInlineMocks() didn't clear their mocking state.
clearInlineMocks() and clearInlineMock(...) left singleton mocks registered, so re-mocking the same instance threw "already registered as a mock" exception.
This PR fixes it:
clearInlineMock(...) removes the instance from that registry: discussed and agreed to not cover.Without the changes, both the newly-introduce unit tests would fail.
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