Is there an existing issue for this?
Current Behavior
I detected a thread pool misuse in DisruptorProviderManage.java using a static analysis tool.
In the startup(boolean isOrderly) method, an OrderlyExecutor (a thread pool) is initialized as a local variable:
OrderlyExecutor executor = new OrderlyExecutor(...)
Although this executor is passed to QueueConsumer, the DisruptorProviderManage class does not retain a reference to it.
Crucially, calling disruptor.shutdown() in DisruptorProvider.shutdown() does NOT automatically shut down external executors. Since the reference to executor is lost after the startup method returns, it is never explicitly shut down.
This leads to a thread pool leak. If the component is restarted or refreshed, the old thread pool remains active, eventually leading to thread exhaustion or OOM.
Expected Behavior
The OrderlyExecutor should be managed properly to ensure resources are released:
- It should be assigned to a class member variable in
DisruptorProviderManage (e.g., private OrderlyExecutor executor;).
- It should be explicitly shut down in the
shutdown() logic (or pass the close responsibility to DisruptorProvider and call executor.shutdown() there).
Steps To Reproduce
- Open
org.apache.shenyu.disruptor.DisruptorProviderManage.java (version 2.6.0).
- Locate the
startup(boolean isOrderly) method (around line 82).
- Observe that
OrderlyExecutor executor = new OrderlyExecutor(...) is a local variable and is not saved to any field.
- Check
org.apache.shenyu.disruptor.provider.DisruptorProvider.java.
- Observe the
shutdown() method: it only calls disruptor.shutdown(), leaving the executor threads running.
Environment
Debug logs
N/A (Issue detected via Static Code Analysis)
Anything else?
This issue was identified by a custom static analysis tool focused on thread pool lifecycle management.
Is there an existing issue for this?
Current Behavior
I detected a thread pool misuse in
DisruptorProviderManage.javausing a static analysis tool.In the
startup(boolean isOrderly)method, anOrderlyExecutor(a thread pool) is initialized as a local variable:OrderlyExecutor executor = new OrderlyExecutor(...)Although this executor is passed to
QueueConsumer, theDisruptorProviderManageclass does not retain a reference to it.Crucially, calling
disruptor.shutdown()inDisruptorProvider.shutdown()does NOT automatically shut down external executors. Since the reference toexecutoris lost after thestartupmethod returns, it is never explicitly shut down.This leads to a thread pool leak. If the component is restarted or refreshed, the old thread pool remains active, eventually leading to thread exhaustion or OOM.
Expected Behavior
The
OrderlyExecutorshould be managed properly to ensure resources are released:DisruptorProviderManage(e.g.,private OrderlyExecutor executor;).shutdown()logic (or pass the close responsibility toDisruptorProviderand callexecutor.shutdown()there).Steps To Reproduce
org.apache.shenyu.disruptor.DisruptorProviderManage.java(version 2.6.0).startup(boolean isOrderly)method (around line 82).OrderlyExecutor executor = new OrderlyExecutor(...)is a local variable and is not saved to any field.org.apache.shenyu.disruptor.provider.DisruptorProvider.java.shutdown()method: it only callsdisruptor.shutdown(), leaving theexecutorthreads running.Environment
Debug logs
N/A (Issue detected via Static Code Analysis)
Anything else?
This issue was identified by a custom static analysis tool focused on thread pool lifecycle management.