apache / apache/shenyu

[Task] Extract shared upstream-data handler base across divide/websocket/grpc (copy-paste + magic strings)

Open
#6,605 1 comment 0 reactions 0 assignees View on GitHub
plugin: divide priority: medium type: refactor
Dominant language
Java
Stars
8.8k
Forks
3.1k
Avg merge
7d 1h
Merged PRs (30d)
85

Description

## Description
Byte-identical `DiscoveryUpstreamData -> Upstream` conversion (Properties-parse -> `Upstream.builder()` with inline `"warmup"/"10"/"gray"/"false"/"healthCheckEnabled"/"true"` literals) duplicated across divide/websocket/grpc. The surrounding null-check->convert->split-gray->submit body is also duplicated verbatim between divide and websocket. The dubbo family already has `AbstractDubboPluginDataHandler` proving the abstraction; divide/websocket/grpc don't use one.

## Location
```
shenyu-plugin-divide/.../DivideUpstreamDataHandler.java:66
shenyu-plugin-websocket/.../WebSocketUpstreamDataHandler.java:59
shenyu-plugin-grpc/.../GrpcDiscoveryUpstreamDataHandler.java:65
(ApacheDubboProxyService.java:171 duplicates conversion a 2nd time within dubbo)
```

## Impact
A bug fix (e.g. warmup default) must be applied 3+ times; the inline magic strings risk per-plugin drift. A typo at one site silently breaks gray/warmup parsing for that plugin only.

## Suggested fix
Lift to a shared `AbstractDiscoveryUpstreamDataHandler` mirroring dubbo's pattern; extract an `UpstreamProps` constant/typed deserializer.

## Related existing issue(s)
None

_Identified during the 2026-08-02 audit; full list in [`docs/issue-candidates-2026-08-02.md`](docs/issue-candidates-2026-08-02.md)._

Contributor guide

No contributing guide indexed for this repository

Research direction

Read the handlers at the listed divide, websocket, and grpc paths, then compare them with AbstractDubboPluginDataHandler and the conversion in ApacheDubboProxyService.java. Trace the duplicated conversion and submission flow first; done means the shared handler and typed property deserialization cover the identified sites without repeated magic-string conversion logic.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.