Skip to content
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

KAFKA-18211: Override class loaders for class graph scanning in connect. #18403

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from

Conversation

snehashisp
Copy link
Contributor

Addresses the issue highlighted in https://issues.apache.org/jira/browse/KAFKA-18211

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@github-actions github-actions bot added triage PRs from the community connect small Small PRs labels Jan 6, 2025
Copy link
Contributor

@gharris1727 gharris1727 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you able to write a regression test for this? Our existing test suite missed this on the library change.

@github-actions github-actions bot removed the triage PRs from the community label Jan 7, 2025
@snehashisp
Copy link
Contributor Author

Yes, made some updates and added a test for this scenario. On a side not, may I get auto approval to run the test suite on my PRs, will help with validating the Multiversion PRs.

@gharris1727
Copy link
Contributor

Sorry about that, clicking the approval button approves a single run and the label approves multiple runs. TIL

@MethodSource("parameters")
public void testClasspathPluginIsAlsoLoadedInIsolation(PluginScanner scanner) {
// json converter is part of the classpath by default
String jsonConverterLocation = JsonConverter.class.getProtectionDomain().getCodeSource().getLocation().getPath();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels very brittle to me.

Rather than using a real class, can this use a TestPlugin with a similar name to a classpath plugin?

Or the last time we needed to set up a "classpath" plugin, it was by injecting a new loader in the hierarchy in PluginsTest#assertClassLoaderReadsVersionFromResource.

Comment on lines +85 to +93
// In addition, we need to explicitly specify the full classloader order, as classgraph only scans the classes available
// in the classloaders and not the entire parent chain. Due to this reason if a plugin is extending a class present
// in classpath/application it will not be able to find the parent class unless we explicitly specify the classloader order.
List<ClassLoader> classLoaderOrder = new ArrayList<>();
ClassLoader cl = source.loader();
while (cl != null) {
classLoaderOrder.add(cl);
cl = cl.getParent();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this true? What is the ignoreParentClassLoaders method doing then?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants