konlue opened a new pull request, #7740:
URL: https://github.com/apache/shenyu/pull/7740
Fixes #7711.
## Summary
The Spring SDK's central response handler has inconsistent status
validation: the typed path accepts only `200 OK`, so successful
`201`/`202`/`204` responses throw `HttpClientErrorException`; and `void`
methods return before any status check, so a `500` is reported to the caller as
normal completion. The raw `ShenyuResponse` return type is an intentional
escape hatch and is left untouched.
## Modifications
- Classify the response status before decoding: accept the full 2xx range
(`HttpStatus.resolve(status).is2xxSuccessful()`), then handle the raw-response
escape hatch, `void` methods and typed body decoding in that order.
- `void` methods now throw `HttpClientErrorException` for non-2xx responses
instead of silently succeeding.
- Typed methods still decode the body only when present, so `204 No Content`
yields `null`.
## Verifying this change
- [x] New tests: `handlerResponseAcceptsAllSuccessfulStatuses` (200/201/202
decode, 204 null),
`handlerResponseThrowsForNonSuccessfulStatusesOnTypedMethods` (400/500),
`handlerResponseValidatesVoidMethods` (500 throws, 204 null) and
`handlerResponseReturnsRawResponseRegardlessOfStatus` (raw response returned
as-is on 500).
- [x] Red-green: the 201 case fails with `HttpClientErrorException: 201
CREATED` and the void-500 case fails with "expected exception, nothing thrown"
on the previous code; all pass with the fix.
- [x] Targeted tests pass:
```bash
./mvnw -B -ntp -pl shenyu-sdk/shenyu-sdk-spring test
-Dtest=ShenyuClientMethodHandlerTest
```
4/4 green (the pre-existing JRE-gated test is skipped).
- [x] Checkstyle passes:
```bash
./mvnw -B -ntp -pl shenyu-sdk/shenyu-sdk-spring checkstyle:check
```
clean.
## Notes
No change to request construction or transport status propagation. Unknown
status codes still surface as `HttpStatus.valueOf(...)` behaviour, as before.
--
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]