-
Notifications
You must be signed in to change notification settings - Fork 3k
Avoid the need to preload mock Kubernetes server classes for Kubernetes tests to pass #48977
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
holly-cummins
merged 1 commit into
quarkusio:main
from
holly-cummins:avoid-kubernetes-preload
Jul 18, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure this is correct, instead of the the variant where we pass the TCCL?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wondered about that. The example I coped did in fact use the TCCL, but I decided the TCCL wasn't the right choice, for two reasons. The first is that it would just go back through the FacadeClassLoader, and the FCL is a kind of expensive way to load classes. (It loads each class twice, and does inspection of the class to decide how to load it.) Because the class we're looking for is a Quarkus class, I decided that the classloader used to load the kube extension would also have good access to the test framework libraries, and could safely load it.
The second reason I didn't use the TCCL is that I wasn't 100% sure what it would be at that point, and whether it would be the FCL or a runtime classloader, and I've been fighting so many (self-inflicted) "TCCL is wrong at this point" chaos-bugs I was nervous to increase our reliance on the TCCL. :)
I think it probably actually doesn't matter, and all three options (FCL, defining classloader, or runtime classloader) would end up delegating to the system classloader. So if you think TCCL is a safer/less surprising choice, happy to change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've also read the docs (which, admittedly, I should have done first, rather than going with intuition), and
Package.getPackages()
uses the caller's classloader, andClass.forName
also uses the caller's classloader. So I've kept parity.Class.forName
does always initialise the class, which could be a waste if it wasn't used, but I think if it's on the classpath it's likely to be used (because if it's not used, the Kubernetes tests will probably fail :) )