feat: use ServiceLoader to find implementations instead of searching classes in jars#5885
feat: use ServiceLoader to find implementations instead of searching classes in jars#5885vlsi merged 1 commit intoapache:masterfrom
Conversation
|
@FSchumacher , @emilianbold, do you remember the reasons for 574ceb6 by chance? UPD: I found the discussion: https://lists.apache.org/thread/sqj1nv0kcls1smy23gyow35fsx51v7sh |
0fb6ce3 to
51ba68f
Compare
46e44ca to
ef24844
Compare
|
It looks like the extra overhead for annotation processing is negligible, so I think we can live with it. I've tried with annotation processinghttps://ge.apache.org/s/td4x7pa3gnddm before this PR |
|
I think the PR is good to go (if the tests pass). I will merge it soon provided there are no objections. |
|
@vlsi you want release 5.5.1 with xalan security fix before merge this PR? Or we prepare the next release 5.6 or 6.0? |
|
I am afraid we have too many changes anyway on the main branch. At the same time, I think Xalan is not the only security fix we need to implement. Do you suggest creating a bugfix branch with xalan only changes? I suggest polishing what we have and releasing it as 5.6. |
…classes in jars ServiceLoader is Java standard approach for locating implementaitons, and it allows pluggability without relying on a filesystem layout. Fixes apache#5883
|
@vlsi, you're crazy man. Why all the changes in one commit? How to understand which interfaces supports new annotation? |
|
@Mingun , please check the tutorial update which comes within the PR: https://github.com/apache/jmeter/pull/5885/files#diff-576fa49214b48be798a06fe0b81dbd6b0276fa58b0c46fd081c278bab7f00a63R183-R184 |
|
The problem is finding those interfaces. It's not pretty easy to find them in 186 changed files. I just cloned repository and find all occurrences of |
|
Try |
Description
ServiceLoader is Java standard approach for locating implementaitons, and it allows pluggability without relying on a filesystem layout.
The change is backward-compatible, so JMeter searches implementations via
ServiceLoader, and then it scans the jars like it was doing previously. However, all the JMeter-provided implementations would be provided as services.Fixes #5883
See discussion https://lists.apache.org/thread/4t7wcjh45q61v300j1954c8l8931swrr
TODO:
JMeterUtils#loadServicesand testsJMeterUtils#findClassesThatExtendusages toServiceLoaderClassFinder#findClassesThatExtendusages toServiceLoaderClassFindermethodsJMeter-Skip-Class-Scanning: truesoClassFinderignores JMeter jarsThe Kotlin Gradle plugin was loaded multiple times in different subprojectswarningOut of scope of the PR:
migrate
MenuFactoryfromClassFinder#findClassesThatExtendMenuFactoryis tricky asServiceLoaderinstantiates services by default, so we can't use it for heavy-weight objects.MenuFactorymakes extra efforts to avoid creating all the GUI components, so we should suggest an alternative.ActionRouter. The code there is involved, and it is not clear why it searches for classes several times (see 574ceb6), implemented in b15439eMotivation and Context
The current
JMeterUtils#findClassesThatExtendandClassFinder.findClassesThatExtendimpose issues:classesfoldersString contains, String notContainsparameters, however, it does not resolve the issue, and it makes an awkward API overall__counterfunction for feat: add property to disable FunctionProperty caching #5788 in:src:coretest module, however,ClassFinderdoes not work there as it wants jar files. After migration toServiceLoader, I could addtestRuntimeOnly(projects.src.functions)dependency, and thenCompoundVariablewould be able to locate functions with aServiceLoader.