Browse Source
Avoid instantiating Plugin class if a plugin is already unloaded
Given the following preconditions:
- `PluginClassLoader` is configured to use `ClassLoadingStrategy` `PDA`, `DPA` or `DAP`.
- There is a `PluginStateListener` that calls `event.getPlugin().getPlugin()`.
- A plugin (`plugin-a`) with a missing dependency is loaded (`plugin-a`).
- The `Plugin` class in `plugin-a` extends, implements or references a class in either
`plugin-b` or in the main application.
In that scenario, when `plugin-a` is unloaded by pf4j, and the `PluginStateListener`
is run, the `event.getPlugin().getPlugin()` call will fail with a `NullPointerException`.
This is caused by the class loading done when instantiating the `Plugin` class in
`plugin-a`. Because not all classes needed are found in `plugin-a` itself, pf4j will
continue by looking up classes in `plugin-a`'s dependencies. Because `plugin-b` is
missing and has no associated `ClassLoader`.
pull/570/head