-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
feat: use ServiceLoader to find implementations instead of searching classes in jars #5885
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 processing
https://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#loadServices
and testsJMeterUtils#findClassesThatExtend
usages toServiceLoader
ClassFinder#findClassesThatExtend
usages toServiceLoader
ClassFinder
methodsJMeter-Skip-Class-Scanning: true
soClassFinder
ignores JMeter jarsThe Kotlin Gradle plugin was loaded multiple times in different subprojects
warningOut of scope of the PR:
migrate
MenuFactory
fromClassFinder#findClassesThatExtend
MenuFactory
is tricky asServiceLoader
instantiates services by default, so we can't use it for heavy-weight objects.MenuFactory
makes 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#findClassesThatExtend
andClassFinder.findClassesThatExtend
impose issues:classes
foldersString contains, String notContains
parameters, however, it does not resolve the issue, and it makes an awkward API overall__counter
function for feat: add property to disable FunctionProperty caching #5788 in:src:core
test module, however,ClassFinder
does not work there as it wants jar files. After migration toServiceLoader
, I could addtestRuntimeOnly(projects.src.functions)
dependency, and thenCompoundVariable
would be able to locate functions with aServiceLoader
.