lymerin opened a new pull request, #7489:
URL: https://github.com/apache/shenyu/pull/7489

   Fixes #7475
   
   ### Problem
   
   With `DefaultRetryStrategy`, `failover` enabled, and retries configured, a 
failed upstream without an explicit port is never excluded.
   
   For the valid upstream configuration `localhost`, ShenYu builds a request 
such as `http://localhost/test`. HTTP uses port 80, but Java's `URI.getPort()` 
returns `-1` because the port was omitted from the URI.
   
   The exclusion check then constructs `getHost() + ":" + getPort()` and 
compares it directly with the configured upstream:
   
   ```text
   Failed request identity: localhost:-1
   Configured upstream:     localhost
   ```
   
   These strings do not match, so the failed upstream remains eligible for 
every retry. HTTPS upstreams with omitted ports have the same problem.
   
   ### Impact
   
   - Failover can repeatedly request the same failed endpoint, consuming 
retries instead of selecting another upstream or returning the existing 
`CANNOT_FIND_HEALTHY_UPSTREAM_URL_AFTER_FAILOVER` error.
   
   - For a single upstream that keeps timing out, this returns 504 instead of 
the existing 503 exhaustion response.
   
   ### Changes
   
   - Parse candidate upstreams through `buildDomain()` and compare scheme, 
host, and effective port, using `UriUtils.getActualPort()`.
   - Exclude path and query parameters from upstream identity.
   - Preserve the existing retry flow, latest-cache lookup, load balancing, 
request-body replay, and error mappings.
   - Add three regression test groups covering:
     - HTTP/HTTPS upstreams without ports, implicit/explicit default-port 
equivalence, and explicit ports with different paths and queries.
     - Selection of upstreams with different hosts, ports, or schemes, 
verifying the actual request URI.
     - Exclusion of a subsequently failed retry upstream and the existing 503 
exhaustion response.
   
   ### Validation
   
   - All 50 HTTP client module tests passed, with zero failures, errors, or 
skipped tests.
   - Checkstyle reported zero violations.
   
   ### Checklist
   
   - [x] You have read the [[contribution 
guidelines](https://shenyu.apache.org/community/contributor-guide)](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`.


-- 
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