shenyu icon indicating copy to clipboard operation
shenyu copied to clipboard

[BUG] isFull clients bypass discovery-mode URI gating, causing dual upstream registration

Open Chrisp12138 opened this issue 4 weeks ago • 0 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues

Current Behavior

When shenyu.discovery.type is set to a registry discovery mode (e.g. nacos), clients are expected to skip local URI registration because upstream instances are sourced from the registry watcher.

Non-isFull clients behave correctly: AbstractContextRefreshedEventListener#onApplicationEvent checks the discovery mode before publishing URI events.

However, isFull=true clients publish meta and URI inside getBeans() and return an empty bean map, so onApplicationEvent returns early at MapUtils.isEmpty(beans) and the discovery-mode gate is never reached.

As a result, in registry discovery mode the admin receives both the local URI registration and the registry-sourced discovery upstreams for the same selector, causing dual upstream registration: local selector-handle rows and registry-watcher discovery rows coexist with diverging weights and duplicate upstream representations.

Expected Behavior

In a registry discovery mode (e.g. nacos), isFull clients should skip local URI registration and let the admin-side registry watcher be the single source of upstreams. Meta registration should still happen so that selectors and rules are created automatically.

Steps To Reproduce

  1. Start shenyu-admin and shenyu-bootstrap (2.7.x).
  2. Configure a springmvc client with isFull=true and shenyu.discovery.type=nacos (plus shenyu.discovery.serverList, shenyu.discovery.register=true).
  3. Start the client service and watch the admin logs / /shenyu-client/register-uri calls.
  4. Observe the divide selector: both the URI registration (selector handle / discovery rows written through doRegisterURI) and the nacos watcher rows exist for the same selector.

Environment

ShenYu version(s):

Debug logs

No response

Anything else?

Root cause: the URI publish of the isFull branch happens before the empty-map early return, so the shenyu.discovery.type check in onApplicationEvent is unreachable for isFull clients (same for SpringWebSocketClientEventListener).

A minimal fix extracts an isDiscoveryLocalMode(context) helper in AbstractContextRefreshedEventListener and gates the URI publish in both isFull branches (meta registration untouched). A PR referencing this issue will follow.

Environment: ShenYu version(s) 2.7.2 / master (2.7.3-SNAPSHOT), Java 17+, MySQL.

Chrisp12138 avatar Nov 05 '26 10:11 Chrisp12138