Sean-Walker0 opened a new pull request, #7420:
URL: https://github.com/apache/shenyu/pull/7420
Fixes #6489
## Modifications
`PathVariableParameterProcessor` and `RequestParamParameterProcessor` each
rebuilt the URL from the **original** `RequestTemplate` (`getUrl() +
getPath()`) and called `setUrl(...)`, so whatever an earlier processor in the
`ShenyuClientMethodHandler` argument loop had already written to
`ShenyuRequest.url` was discarded. For a method mixing both annotations:
- `@PathVariable` first, `@RequestParam` second → the request-param
processor rebuilt from the raw template path and reintroduced the unresolved
placeholder: `/orders/{id}?expand=all`;
- `@RequestParam` first, `@PathVariable` second → the path-variable
processor overwrote the query string: `/orders/one` (query lost).
Both processors now mutate the live URL in place:
`RequestTemplate#request()` initializes `ShenyuRequest.url` to `url + path`, so
substituting `{name}` placeholders and appending query parameters on the
current value makes the two rewrites compose in any declaration order:
```java
// PathVariable: replace on the current URL
shenyuRequest.setUrl(RegExUtils.replaceAll(shenyuRequest.getUrl(),
varNameRegex, String.valueOf(arg)));
// RequestParam: append to the current URL
StringBuilder urlResult = new StringBuilder(shenyuRequest.getUrl());
```
## Verifying this change
- [x] New `ParameterProcessorUrlCompositionTest` — both declaration orders;
red on the pre-fix code (`expected: <…/orders/one?expand=all> but was:
<…/orders/{id}?expand=all>` and `but was: <…/orders/one>`), green after.
- [x] Existing `PathVariableParameterProcessorTest` /
`RequestParamParameterProcessorTest` fixtures aligned with the runtime
initialization (`RequestTemplate#request()` sets `url + path`; they previously
passed an empty URL — assertions unchanged).
- [x] `./mvnw -pl shenyu-sdk/shenyu-sdk-spring -am test -B` — 33/33 module
tests green (4 pre-existing JRE-conditional skips), checkstyle clean.
## Notes
- Behavior change: only for methods mixing `@PathVariable` and
`@RequestParam` — both rewrites now survive each other. Single-annotation
methods produce the same URL as before.
- Test-fixture adjustment is disclosed above; it does not weaken any
assertion.
- Orthogonality: no open PR touches `shenyu-sdk/` (verified against the file
lists of all 92 open PRs).
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 clean install
-Dmaven.javadoc.skip=true` (module-scoped: `shenyu-sdk/shenyu-sdk-spring` with
`-am`, tests + checkstyle green).
--
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]