Skip to content

[BUG] Resource leak in shenyu-disruptor: OrderlyExecutor is not shut down properly #6262

@QiuYucheng2003

Description

@QiuYucheng2003

Is there an existing issue for this?

  • I have searched the existing issues

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:

  1. It should be assigned to a class member variable in DisruptorProviderManage (e.g., private OrderlyExecutor executor;).
  2. 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

  1. Open org.apache.shenyu.disruptor.DisruptorProviderManage.java (version 2.6.0).
  2. Locate the startup(boolean isOrderly) method (around line 82).
  3. Observe that OrderlyExecutor executor = new OrderlyExecutor(...) is a local variable and is not saved to any field.
  4. Check org.apache.shenyu.disruptor.provider.DisruptorProvider.java.
  5. Observe the shutdown() method: it only calls disruptor.shutdown(), leaving the executor threads running.

Environment

ShenYu version(s):2.6.0

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions