Skip to content

Feature: Cache ClassLoader for pluginDir#88

Open
infeo wants to merge 1 commit intodevelopfrom
feature/cache-classloader
Open

Feature: Cache ClassLoader for pluginDir#88
infeo wants to merge 1 commit intodevelopfrom
feature/cache-classloader

Conversation

@infeo
Copy link
Member

@infeo infeo commented Mar 20, 2026

This PR changes the loading of plugins.

Currently, calling IntegrationsLoader::loadX method creates a new class loader. The class loader completely traverses the pluginDirectory. If there are many plugins or deeply nested ones, loading specific services takes a long time. Every time a certain service is loaded.

This PR adds a thread-safe, lazily initialized cache for the class loader, which is initialized once and never invalidated. It reduces the look up time of consecutive service implementations and ensures that only one file handle to each plugin file is created.

Important implication is, that once any service is loaded, changes to the plugin directory or the plugin directory property have no effect.

and lazily initialize it
@infeo infeo self-assigned this Mar 20, 2026
@infeo infeo added this to the next milestone Mar 20, 2026
@coderabbitai
Copy link

coderabbitai bot commented Mar 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 09ce1ffa-a363-4f90-813e-864cf895325d

📥 Commits

Reviewing files that changed from the base of the PR and between e833e27 and 71bcf11.

📒 Files selected for processing (2)
  • src/main/java/org/cryptomator/integrations/common/ClassLoaderFactory.java
  • src/main/java/org/cryptomator/integrations/common/IntegrationsLoader.java

Walkthrough

The changes introduce a cached, lazily-initialized plugin ClassLoader in IntegrationsLoader through a new inner class PluginClassLoaderHolder and corresponding accessor method. This replaces repeated direct calls to ClassLoaderFactory.forPluginDir() with a single shared instance. Additionally, Javadoc for ClassLoaderFactory.forPluginDir() was updated to clarify that the returned URLClassLoader loads classes from the "given directory" rather than "given classes."

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: caching a ClassLoader for the plugin directory, which is the core objective of the pull request.
Description check ✅ Passed The description is directly related to the changeset, explaining the motivation, implementation approach, and implications of caching the ClassLoader for plugin loading.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/cache-classloader

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

You can make CodeRabbit's review stricter and more nitpicky using the `assertive` profile, if that's what you prefer.

Change the reviews.profile setting to assertive to make CodeRabbit's nitpick more issues in your PRs.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant