-
Notifications
You must be signed in to change notification settings - Fork 166
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
fix: Classes should not be loaded from the plugin #19010
Conversation
Quality Gate passedIssues Measures |
Does @mcollovati, @platosha or somebody else know why this should not be done? The current implementation finds Flow classes the plugin was built with and not from the project. No tests here fail, does Hilla rely on this somehow? |
The only reason I can see against Looking at the flow maven plugin code, it looks like we provide all runtime dependencies ( I wonder if we should provide to |
The Surefire plugin for in-process execution uses a custom class loader, temporarily set as the current thread context class loader. The classloader is built on project dependencies ( @Override
public RunResult invoke(Object forkTestSet) throws ReporterException, InvocationTargetException {
ClassLoader current = swapClassLoader(testsClassLoader);
try {
Method invoke = getMethod(providerInOtherClassLoader.getClass(), "invoke", INVOKE_PARAMETERS);
Object result = invokeMethodWithArray2(providerInOtherClassLoader, invoke, forkTestSet);
return (RunResult) surefireReflector.convertIfRunResult(result);
} finally {
if (System.getSecurityManager() == null) {
Thread.currentThread().setContextClassLoader(current);
}
}
}
private ClassLoader swapClassLoader(ClassLoader newClassLoader) {
ClassLoader current = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(newClassLoader);
return current;
} |
and presumably the built test classloader does not use the plugin classloader as its parent? |
If I got it correctly, it uses the platform classloader as parent. |
Added the platform classloader as parent.. |
Quality Gate passedIssues Measures |
Should we merge this for 24.6 or try to figure out if it breaks something or is there some better approach? |
Quality Gate passedIssues Measures |
Building a hybrid application with this change results in an error
|
I think the missing piece here is to make the Flow mojos set the I wonder if the previous error can be fixed by applying the same pattern to the Hilla |
Isolating the execution so that flow-server classes are not loaded into the plugin class loader seems to be more complicated than expected. |
Changing the thread context class loader during mojo execution does not work. flow-server classes are still loaded into the plugin class loader, causing a |
Also, making |
Superseded by #20465 |
Related-to #19009