[BUG] Tars ApplicationConfigCache: four unbounded ConcurrentHashMaps never evicted (class-loader leak)
- Dominant language
- Java
- Stars
- 8.8k
- Forks
- 3.1k
- Avg merge
- 7d 1h
- Merged PRs (30d)
- 85
Description
## Description
Only the `LoadingCache cache` (line 82) has a `maximumSize`. Four companion maps (`ctxPathCache`, `prxClassCache`, `prxParamCache`, `refreshUpstreamCache`) have no maximumSize, no expiry, and no removal path. `invalidate(contextPath)` only calls `cache.invalidate(path)`. `prxClassCache` holds ByteBuddy-generated `Class` objects loaded via `ClassLoadingStrategy.Default.INJECTION`; each retained `Class` pins its class-loader and prevents metaspace GC.
## Location
```
shenyu-plugin-tars/.../cache/ApplicationConfigCache.java:92,94,96,98 (maps), 349-352 (invalidate only touches bounded LoadingCache)
:269 (ClassLoadingStrategy.Default.INJECTION)
```
## Impact
Long-lived deployments that add/remove Tars services (blue-green, ephemeral environments) leak generated Class objects + loaders forever -> eventual `Metaspace OOM`. Worst kind of leak (prevents metaspace reclamation).
## Suggested fix
In `invalidate(contextPath)`, also remove `ctxPathCache.remove(contextPath)` and, for each MetaData in that list, `prxClassCache.remove(metaData.getPath())` and `prxParamCache` entries. Wire `TarsMetaDataHandler.remove` to the full cleanup.
## Related existing issue(s)
None
_Identified during the 2026-08-02 audit; full list in [`docs/issue-candidates-2026-08-02.md`](docs/issue-candidates-2026-08-02.md)._
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in shenyu-plugin-tars/.../cache/ApplicationConfigCache.java, especially the four maps at lines 92-98, ClassLoadingStrategy.Default.INJECTION at line 269, and invalidate(contextPath) at lines 349-352. Trace TarsMetaDataHandler.remove and the metadata paths, then verify that invalidation removes related entries from every companion cache and no generated classes or class-loaders remain retained.
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
- 55/100