Class PluginClassLoaderCachePurger

java.lang.Object
com.xebialabs.xlrelease.osgi.spring.PluginClassLoaderCachePurger

public final class PluginClassLoaderCachePurger extends Object
Purges the enumerable set of JDK/Spring caches that would otherwise pin a departing plugin's classloader - a hand-rolled list, after rejecting ClassLoaderLeakPreventor (stale since 2016, and its API assumes a ServletContextEvent rather than an arbitrary ClassLoader). Called from PluginTeardown step 8.

The first two calls are classloader-scoped (they clear only classLoader's entries); the rest are process-wide static caches with no classloader-scoped overload - clearing them on every plugin teardown is safe (they are pure performance caches, rebuilt lazily on next access) but is a minor, shared cost across all plugins, not specific to the one being removed. CachedIntrospectionResults/ResourceBundle are the ones that actually pin the leaving classloader.

Plugin-author contract - what this purge does NOT cover:

  • No unmanaged threads/ScheduledExecutorService - plugins must use a host-provided, plugin-scoped executor (no such executor exists yet in v1; noted as a follow-up).
  • No ThreadLocal left set on shared/pooled threads.
  • No direct host event-bus @AsyncSubscribe - must use PluginEventSubscriptions, whose handles PluginTeardown closes automatically.
  • No JDBC driver registration, no JMX/MBean registration, no Logback appender registration from plugin code.
None of the above is statically validated at install time in v1 (an explicitly deferred enhancement, not required for this plan to merge).
  • Method Details

    • purge

      public static void purge(ClassLoader classLoader)