Aias00 opened a new issue, #6726:
URL: https://github.com/apache/shenyu/issues/6726
- Severity: Medium-High
- Location:
`shenyu-web/src/main/java/org/apache/shenyu/web/loader/ShenyuPluginClassLoaderHolder.java:51-58`
(same pattern at `:66-69`)
-
Description:
`if (pluginCache.containsKey(jarKey)) { pluginCache.remove(jarKey).close();
} pluginCache.put(jarKey, shenyuPluginClassLoader);` — three separate
`ConcurrentHashMap` ops, not atomic. Two threads creating a classloader for the
same `jarKey` race: T1 removes+closes old; T2's `containsKey` returns false so
it skips close; T2 `put`s CL2; T1 `put`s CL1 overwriting CL2. CL2 is orphaned —
never closed, its Spring beans never destroyed — and lost to callers.
-
Impact:
Classloader + Spring bean leak; the returned classloader can be one whose
beans were already destroyed by a concurrent `close()`.
-
Suggested fix:
Use `pluginCache.compute(jarKey, (k, old) -> { if (old != null) old.close();
return shenyuPluginClassLoader; })`.
-
Confidence: Medium-High
- 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)._
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]