apache / apache/shenyu

[BUG] DisruptorProviderManage.startup is not idempotent — leaks disruptor + executor on re-entry

Open
#6,776 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-disruptor/src/main/java/org/apache/shenyu/disruptor/DisruptorProviderManage.java:98-134`
-
Description:
`startup()` unconditionally constructs a new `OrderlyExecutor`, a new `Disruptor`, new `QueueConsumer`s, and overwrites `this.provider` without shutting down any prior instance. No guard (`provider != null`) and no shutdown of previously-assigned disruptor/executor. Threads are `daemon=false`.
-
Impact:
Any code path calling `startup()` a second time (reconnect, re-init, retry, test re-entry) leaks the previous Disruptor's non-daemon provider threads plus `OrderlyExecutor`/`SingletonExecutor` threads; prevents JVM exit and grows thread counts.
-
Suggested fix:
Guard with `AtomicBoolean started`; on re-entry `if (provider != null) shutdown()` first; make `startup` idempotent.
-
Confidence: Medium
- Related existing: none — #6262 is `shutdown()` not closing executor; this is `startup()` not closing the *previous* instance on re-entry.

---
_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 with startup() in shenyu-disruptor/src/main/java/org/apache/shenyu/disruptor/DisruptorProviderManage.java:98-134 and trace how the provider, Disruptor, QueueConsumers, OrderlyExecutor, and SingletonExecutor are created. Exercise startup() twice, then verify the prior instance is shut down, no duplicate non-daemon threads remain, and the JVM can exit; use docs/scan2-2026-08-02/06-medium-tiers.md for the scan context.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.