[BUG] ExtensionLoader pinned to first ClassLoader; plugin-contributed SPI extensions invisible
- Dominant language
- Java
- Stars
- 8.8k
- Forks
- 3.1k
- Avg merge
- 7d 1h
- Merged PRs (30d)
- 85
Description
- Severity: Medium
- Location:
`shenyu-spi/src/main/java/org/apache/shenyu/spi/ExtensionLoader.java:102-107` (`putIfAbsent` keeps first loader), `:78` (classloader stored at construction), `:268-271` (`loadDirectory` calls `classLoader.getResources` only on pinned loader)
-
Description:
`getExtensionLoader(clazz, cl)` caches `ExtensionLoader` by `Class` only. `putIfAbsent` keeps the first loader (typically app classloader). `loadDirectory` calls `classLoader.getResources("META-INF/shenyu/")` on that pinned loader. A later call with a plugin `ClassLoader` returns the cached app-classloader loader, so the plugin's `META-INF/shenyu/...` SPI files are never enumerated.
-
Impact:
Plugin-contributed SPI extensions silently don't load; `getJoin(name)` throws `IllegalArgumentException` at runtime for the contributed name. The SPI subsystem cannot be extended by hot-deployed plugins.
-
Suggested fix:
Enumerate resources across all registered classloaders (merge results, last-wins or error-on-dup), or key `LOADERS` by `(clazz, classLoader)`.
-
Confidence: Medium
- Related existing: none
---
_Identified during the 2026-08-02 deep re-scan; full list in [`docs/scan2-2026-08-02/06-medium-tiers.md`](docs/scan2-2026-08-02/06-medium-tiers.md)._
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in shenyu-spi/src/main/java/org/apache/shenyu/spi/ExtensionLoader.java, focusing on getExtensionLoader, the cached classloader, loadDirectory, and getJoin. Reproduce loading a plugin-contributed META-INF/shenyu/ resource with a later ClassLoader. Done means those resources are enumerated and the contributed extension name no longer causes getJoin(name) to throw.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100