apache / apache/shenyu

[BUG] MCP buildURIRegisterDTO returns null — null disruptor events published in local discovery mode

Closed
#6,789 1 comment 0 reactions 0 assignees View on GitHub
feature: plugin 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-client/shenyu-client-mcp/shenyu-client-mcp-register/src/main/java/org/apache/shenyu/client/mcp/McpServiceEventListener.java:105-107`; consumed at `shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/client/AbstractContextRefreshedEventListener.java:155-158`
-
Description:
`buildURIRegisterDTO` returns `null`. The parent `onApplicationEvent` does not null-check the result and, in local discovery mode (the default: `shenyu.discovery.type` defaults to `DISCOVERY_LOCAL_MODE`), calls `publisher.publishEvent(buildURIRegisterDTO(...))` once per namespace — i.e. `publisher.publishEvent(null)`. `ShenyuClientRegisterEventPublisher.publishEvent` → `DisruptorProvider.onData(null)` → `ringBuffer.publishEvent(translatorOneArg, null)`, enqueuing a null `DataTypeParent` for `ShenyuClientURIExecutorSubscriber` to process. Every other client (SOFA `:75`, Tars `:106`, WebSocket `:123`) returns a real `URIRegisterDTO`.
-
Impact:
Repeated null events enter the register disruptor on every context refresh in default discovery mode; the subscriber NPEs on the null payload. The disruptor swallows the exception to logs (no crash), but spams errors and wastes queue slots.
-
Suggested fix:
Return a real (minimal) `URIRegisterDTO` for MCP, or make the parent skip `publishEvent` when `buildURIRegisterDTO` returns null, or override discovery handling so URI publishing is bypassed for MCP.
-
Confidence: Medium
- Related existing: none — FUNC-B4 (`ShenyuClientURIExecutorSubscriber block forever`) is a different subscriber defect.

---
_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 buildURIRegisterDTO in shenyu-client-mcp/shenyu-client-mcp-register/src/main/java/org/apache/shenyu/client/mcp/McpServiceEventListener.java and trace its caller in AbstractContextRefreshedEventListener.java. Compare the MCP listener with the SOFA, Tars, and WebSocket implementations, then verify local discovery no longer publishes null payloads to the disruptor or triggers the subscriber error.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.