-
Notifications
You must be signed in to change notification settings - Fork 46
Let engine utContext.classLoader
fallback to UtBot own class path
#2556
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
Conversation
|
||
override fun getResource(name: String): URL? { | ||
var res: URL? = commonParent.getResource(name) | ||
if (res === null) { |
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.
Minor:
Why do you use ===
here? Previously, you used ==
.
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.
Intellij IDEA reports a warning when equals
(==
) is used for URL
saying it may perform a DNS lookup, using reference equality helps to avoid the warning.
// - Finally, if all else fails we try to load class/resource from UtBot classpath | ||
// - at this step we load classes from UtBot project and its dependencies (e.g. Mockito if user doesn't have it, see #2545) | ||
UtContext.setUtContext(UtContext( | ||
FallbackClassLoader( |
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.
Minor:
Extract it to variable
UtContext.setUtContext(UtContext( | ||
FallbackClassLoader( | ||
urls = params.classpathForUrlsClassloader.map { File(it).toURI().toURL() }.toTypedArray(), | ||
fallback = ClassLoader.getSystemClassLoader(), |
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.
Minor:
Extract it to variable
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.
LGTM, though there are some minors
Description
Fixes #2523 by utilizing child first class loader.
Additional context
#2523 is a regression caused by #2479, however we can't revert #2479, because otherwise UtBot classpath would be prioritized over user's classpath, causing issues when user and UtBot use different versions of same library. This PR makes it so UtBot classpath is still used, but only if the class is not found on the user classpath.
How to test
Manual tests
Scenario from issue should no longer reproduce
Self-check list