#8932 : check JDK running to avoid using SpringBusFactory as default#1445
#8932 : check JDK running to avoid using SpringBusFactory as default#1445laurentschoelens wants to merge 1 commit intoapache:mainfrom
Conversation
|
Thanks for the pull request @laurentschoelens , I don't think this is the path we should take: the unfortunate fact is that nonetheless the dependencies are declared optional, Apache Maven eagerly brings them, I've opened the pull request to fix thar here #1446 |
|
@reta : in fact, marking a dependency Take module A / B / C :
Here, codegen does have spring dependency as direct dependency, even if marked as optional (which has no effect cause final artifact). Another fix would be to check if codegen really depends on spring classes (inside his own module) and remove it if nod needed. |
By doing so, it will never use SpringBusFactory has default BusFactory, even on JDK17. Don't know if that you really want to do. |
Correct, but if the dependency is not available at runtime, the application will fail (if is not mitigated)
The optional part indeed was not sufficient hence the |
Here having it with default scope but only Optional will bring it on runtime by default when execution B as application.
Doing so you'll always get the failing "ClassNotFoundException" with no more usage of SpringBusFactory on plugins. |
The are part of the codebase that works by introspection of classpath, like in this concrete example, if Spring is available on the classpath, the SpringBus would be picked.
... or application, which is exactly the goal |
Sorry to insists, just to be sure the changes made are OK
Does the plugin gets dependencies of the maven module ? catch (NoClassDefFoundError | ClassNotFoundException var10) {
busFactoryClass = "org.apache.cxf.bus.CXFBusFactory";
}The only way to get rid of this, is by adding spring as direct dep of the plugin |
It is configured by
The |
|
Understood for jdk9 forking : that's why it always forks even if putting fork attribute to If spring is not used by codegen, why should you not remove the dependency ? |
Spring is not used by codegen (and other plugins) directly but dependencies of the plugin, I sadly don't know for sure the reasons, I could only guess but if the project depends on Spring, there are different classpath scanners etc the plugin could use (this is purely speculation) |
So maybe just remove the spring dependencies of the plugins : making it optional-provided in plugin's pom is quite non-sense to me if not used |
Having these dependencies explicitly listed protects from any possible leakage of transitive Spring dependencies into the plugins, accidental or not (we may remove it the future, however I am concerned at this point to not break anyone's build in case there was reliance on Spring presence) |
|
Ok. |
Tested OK against project sample in issue https://issues.apache.org/jira/browse/CXF-8932
Got the following output running JDK11