fix(compat): restore junit5 compatibility to LocallyRunOperatorExtension#3355
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR adds a runtime fallback for registering CrdCleanup to retain compatibility across different JUnit 5 ExtensionContext.Store API versions.
Changes:
- Introduced a
try/catch (NoSuchMethodError)fallback fromcomputeIfAbsenttogetOrComputeIfAbsent. - Refactored store access into a local
storevariable for reuse.
Comment on lines
+366
to
+371
| try { | ||
| store.computeIfAbsent(CrdCleanup.class, ignored -> new CrdCleanup(deleteCRDs)); | ||
| } catch (NoSuchMethodError nsme) { | ||
| // Exists to retains compatibility with Junit5. | ||
| store.getOrComputeIfAbsent(CrdCleanup.class, ignored -> new CrdCleanup(deleteCRDs)); | ||
| } |
Contributor
Author
There was a problem hiding this comment.
Not too convinced by Copilot's advice here. The reminder why the call to the deprecated method is made is helpful IMO. Using reflection would be overkill.
Signed-off-by: Keith Wall <[email protected]>
xstefank
approved these changes
May 15, 2026
Collaborator
xstefank
left a comment
There was a problem hiding this comment.
LGTM, since this should not break JUnit 6, I don't see why not merge it.
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.
As described by #3354, this change restores Junit5 compatibility for users using LocallyRunOperatorExtension in a stack that has not upgraded to Junit6.