apache / apache/shenyu

[BUG] Plugin beans keyed by simple class name — cross-plugin collision during close/reload

Open
#6,730 1 comment 0 reactions 0 assignees View on GitHub
priority: medium type: bug
Dominant language
Java
Stars
8.8k
Forks
3.1k
Avg merge
7d 1h
Merged PRs (30d)
85

Description

- Severity: Medium
- Location:
`shenyu-plugin/shenyu-plugin-api/src/main/java/org/apache/shenyu/plugin/api/utils/SpringBeanUtils.java:138-143` (`getBeanName` lowercases simple class name); `shenyu-web/src/main/java/org/apache/shenyu/web/loader/ShenyuPluginClassLoader.java:142-147` (`close()` iterates all class names and calls `destroyBean(clazzName)`)
-
Description:
`getBeanName(className)` uses the simple class name (lowercased first char) as the Spring bean name. Two plugins with a class of the same simple name share one bean slot. `close()` iterates `pluginJar.getClazzMap().keySet()` and calls `destroyBean(clazzName)` for every class in the jar — including names that may now be backed by a *different* classloader if another plugin defines the same simple name, or if a reload race caused the new CL to re-register before the old CL's `close()` runs.
-
Impact:
`close()` of one plugin destroys another plugin's live bean → `BeanCreationException`/NPE on the surviving plugin at request time.
-
Suggested fix:
Namespace bean names by classloader/jarKey (e.g. `beanName = jarKey + "#" + simpleName`); have `close()` only destroy beans it actually registered.
-
Confidence: Medium
- Related existing: none

---

## E. Gateway-side data sync apply path (3 findings)

---
_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

Read SpringBeanUtils.java:138-143 and ShenyuPluginClassLoader.java:142-147, then trace how pluginJar.getClazzMap() and destroyBean are used during close and reload. Confirm how bean names are registered and destroyed; done means closing one plugin cannot destroy a bean registered by another plugin or a newer classloader.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.