imDwAaY opened a new pull request, #7810:
URL: https://github.com/apache/shenyu/pull/7810
Fixes #7801
## Problem
When an upstream returns a valid non-standard HTTP status code (for example
`529`) and the response has been decorated by a plugin such as
`loggingConsole`, `NettyHttpClientPlugin` fails to propagate the status:
- `HttpStatus.resolve(529)` returns `null` because `529` is not in Spring's
`HttpStatus` enum.
- The fallback path requires `response instanceof
AbstractServerHttpResponse`, but `ServerHttpResponseDecorator` only implements
the `ServerHttpResponse` interface and does not extend that abstract class.
- The client therefore throws `IllegalStateException`, and after retry
translation the caller receives `408 REQUEST_TIMEOUT` with an empty body.
Standard status codes are unaffected because they take the `HttpStatus`
branch.
## Change
Set the status through the `ServerHttpResponse` interface so it works for
both decorated and undecorated responses:
```java
response.setStatusCode(HttpStatusCode.valueOf(res.status().code()));
```
`HttpStatusCode.valueOf(code)` returns `HttpStatus` for known codes
(preserving existing behavior) and `DefaultHttpStatusCode` for non-standard
codes. The concrete-type check and the now-unused imports are removed.
## Verification
- New regression test `testNonStandardStatusWithDecoratedResponse`:
- fails on the previous code with `IllegalStateException: Unable to set
status code on response: 529, class
org.springframework.http.server.reactive.ServerHttpResponseDecorator`
- passes with this change and asserts the forwarded status is `529`
- `./mvnw -pl shenyu-plugin/shenyu-plugin-httpclient test -Drat.skip=true
-Djacoco.skip=true` → 67 tests, 0 failures
- `./mvnw -pl shenyu-plugin/shenyu-plugin-httpclient checkstyle:check` → 0
violations
--
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]