MINOR: Refactor DelegatingClassLoader to emit immutable PluginScanResult#13771
MINOR: Refactor DelegatingClassLoader to emit immutable PluginScanResult#13771C0urante merged 14 commits intoapache:trunkfrom
Conversation
Signed-off-by: Greg Harris <greg.harris@aiven.io>
C0urante
left a comment
There was a problem hiding this comment.
Thanks Greg. Some minor stylistic comments. Also not sure we should be modifying the aliasing logic without a very good reason; let me know if there's implications that I'm missing.
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/isolation/PluginScanResult.java
Show resolved
Hide resolved
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/isolation/PluginScanResult.java
Outdated
Show resolved
Hide resolved
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/isolation/PluginScanResult.java
Outdated
Show resolved
Hide resolved
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/isolation/PluginDesc.java
Outdated
Show resolved
Hide resolved
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/isolation/PluginUtils.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Greg Harris <greg.harris@aiven.io>
Signed-off-by: Greg Harris <greg.harris@aiven.io>
…l class name. Signed-off-by: Greg Harris <greg.harris@aiven.io>
Signed-off-by: Greg Harris <greg.harris@aiven.io>
|
Thanks Greg! I think the tradeoffs here are acceptable. Can we add some testing coverage for |
Signed-off-by: Greg Harris <greg.harris@aiven.io>
|
Here's an example of the new log message, pulled from the test run: |
C0urante
left a comment
There was a problem hiding this comment.
Thanks Greg! Really appreciate the added testing coverage for alias computation. Some small test comments and one logging suggestion and then this should be good to go.
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/isolation/PluginUtilsTest.java
Outdated
Show resolved
Hide resolved
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/isolation/PluginUtilsTest.java
Outdated
Show resolved
Hide resolved
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/isolation/PluginUtilsTest.java
Outdated
Show resolved
Hide resolved
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/isolation/PluginUtilsTest.java
Outdated
Show resolved
Hide resolved
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/isolation/PluginUtilsTest.java
Outdated
Show resolved
Hide resolved
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/isolation/PluginUtils.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Greg Harris <greg.harris@aiven.io>
Signed-off-by: Greg Harris <greg.harris@aiven.io>
C0urante
left a comment
There was a problem hiding this comment.
Thanks Greg! LGTM
Will merge pending CI build
Signed-off-by: Greg Harris <greg.harris@aiven.io>
Signed-off-by: Greg Harris <greg.harris@aiven.io>
|
@gharris1727 there are test failures in the latest CI run. Can you look into those? Feel free to just rebase on the latest trunk if that's all that's required. |
…ions Signed-off-by: Greg Harris <greg.harris@aiven.io>
|
Test failures appear unrelated (there is a known bug in the reflections library that we use that caused a test failure which may appear related, but is not). Merging... |
The DelegatingClassLoader has a large number of fields and methods for keeping track of known PluginDesc objects. It has this in common with the PluginScanResult data object, which has a similar set of fields and methods. On trunk, the PluginScanResult is only used as a return value of one internal function, before it's results are accumulated by the DCL and discarded. To simplify the DCL, we should use the PluginScanResult object as a container to store and accumulate PluginDesc objects, and return it to the caller to allow them to inspect the scanned plugins without interacting with the DCL.
Using the PluginScanResult as an accumulator, we can delay writing scan results to the pluginLoaders and aliases fields until after all scanning has taken place. This is done via the new installDiscoveredPlugins method. This prevents plugins being scanned from having an inconsistent delegation path: Previously, because the accumulators were updated as scanning proceeded, plugins may or may not be able to see one another via the DelegatingClassLoader::loadClass method. Now, plugins will not be able to see one another before installDiscoveredPlugins is applied and scanning is finished.
This is a first-pass refactor, before pulling the scanning logic out of the DCL to further simplify it. Once external scanning is complete, the caller will call installDiscoveredPlugins to finish initialization of the DCL.
In the trunk implementation, there is some order-sensitivity to the scanning process because of the accumulator fields. In particular:
Committer Checklist (excluded from commit message)