Sean-Walker0 opened a new pull request, #7325:
URL: https://github.com/apache/shenyu/pull/7325

   <!-- Describe your PR here; e.g. Fixes #issueNo -->
   Found by code audit (no existing issue — happy to file one if maintainers 
prefer).
   
   `CacheUpstream#CacheUpstream(Builder)` has an **empty constructor body** — 
none of the builder's fields are copied, so 
`CacheUpstream.builder()....build()` always returns an all-defaults instance 
and silently discards every configured value (cacheType, url, database, host, 
protocol, upstreamUrl, status, timestamp, password, master, mode, pool 
settings). The sibling `DubboUpstream`/`SofaUpstream` builder constructors copy 
each field, confirming the intended pattern this class forgot. Current callers 
only reach `CacheUpstream` through Gson deserialization 
(`CachePluginDataHandler`), so the defect is latent today — but any 
builder-based construction yields a default-protocol, default-url upstream with 
no error.
   
   <!--
   Thank you for proposing a pull request. This template will guide you through 
the essential steps necessary for a pull request.
   -->
   Make sure that:
   
   - [x] You have read the [contribution 
guidelines](https://shenyu.apache.org/community/contributor-guide).
   - [x] You submit test cases (unit or integration tests) that back your 
changes.
   - [x] Your local test passed `./mvnw test -pl shenyu-common -am and ./mvnw 
checkstyle:check -pl shenyu-common` (module-scoped; full build left to CI).
   
   ### Modifications
   
   - Fill in the builder constructor, mirroring `DubboUpstream`: parent fields 
via setters (`upstreamHost`, `protocol`, `upstreamUrl`, `status` with the 
`defaultStatus()` fallback when unset, `timestamp`), own fields by direct 
assignment (`cacheType`, `url`, `password`, `database`, `master`, `mode`, 
`maxIdle`, `minIdle`, `maxActive`, `maxWait`).
   
   ### Verifying this change
   
   - New `CacheUpstreamTest#testBuilderCopiesAllStateIntoBuiltInstance` builds 
an instance with distinct values for every reachable builder property and 
asserts each one survives. It fails on current master with `expected: <host-1> 
but was: <null>` and passes with this change.
   - Full `shenyu-common` module suite green; checkstyle green.
   
   ### Notes
   
   - Behavior change: none for existing callers (Gson path bypasses the 
builder); builder-based construction now works instead of silently returning 
defaults.
   - Noted while fixing: the `Builder` also declares 
`password/master/mode/maxIdle/minIdle/maxActive/maxWait` fields but exposes no 
fluent methods for them, and a `weight` field with no matching `CacheUpstream` 
field — left untouched as out of scope; happy to follow up if maintainers want 
the builder completed.
   - Orthogonal to open PRs: no open PR touches `CacheUpstream`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to