Aias00 opened a new issue, #7475:
URL: https://github.com/apache/shenyu/issues/7475

   ## Description
   
   `DefaultRetryStrategy` excludes the failed upstream by comparing each 
candidate upstream URL to `needToExclude.getHost() + ":" + 
needToExclude.getPort()`. For a URI such as `http://localhost/test`, Java 
reports `getPort() == -1`. ShenYu accepts upstream URLs without explicit ports 
and treats them as default ports in `UpstreamCheckUtils`, while 
`Upstream.buildDomain()` preserves the no-port form. As a result, a failed 
`http://localhost/test` attempt is compared as `localhost:-1` against the 
configured upstream `localhost`, so the same upstream remains eligible for 
failover.
   
   ## Location
   
   - 
`shenyu-plugin/shenyu-plugin-httpclient/src/main/java/org/apache/shenyu/plugin/httpclient/DefaultRetryStrategy.java:116`
   - 
`shenyu-common/src/main/java/org/apache/shenyu/common/utils/UpstreamCheckUtils.java:73`
   - 
`shenyu-loadbalancer/src/main/java/org/apache/shenyu/loadbalancer/entity/Upstream.java:471`
   
   ## Expected Behavior
   
   Failover should normalize scheme, host, and effective port before excluding 
the failed upstream. If the only remaining candidate is the same failed 
upstream, failover should return the existing cannot-find-healthy-upstream 
error instead of retrying it.
   
   ## Actual Behavior
   
   Failover can select the same implicit-port upstream again. The scratch repro 
prints the same URI for the original attempt and the failover attempt:
   
   ```text
   http://localhost/test
   http://localhost/test
   ```
   
   ## Impact
   
   Rules that configure host-only upstreams (`localhost`, `example.com`, 
`https://example.com`) can spend their failover retry budget on the same failed 
endpoint, reducing availability exactly when failover is expected to route 
around an unhealthy upstream.
   
   ## Suggested Fix
   
   Normalize both sides to a canonical upstream identity before comparing, for 
example `scheme + host + effectivePort`, where missing `http` and `https` ports 
resolve to 80 and 443. Add a regression test with current URI 
`http://localhost/test` and upstream URL `localhost`.
   
   ## Evidence
   
   - Scratch repro: 
`.omx/reports/code-review-batch20/http/repro/FailoverImplicitPortRepro.java`
   - Related existing distinction: #6734 covers 5xx responses not entering 
failover; this issue happens after failover is already active and concerns 
failed-upstream exclusion identity.
   
   
   ## Reviewed Revision And Validation
   
   Apache ShenYu 2.7.2-SNAPSHOT, master at 
a89b6a2338c24e978428b731e8f1edce86022418. Severity: medium. Confidence: high.
   
   Actual retry-strategy scratch harness reproduced choosing the same 
implicit-port endpoint after failover.
   
   Current source references:
   
   - 
`shenyu-plugin/shenyu-plugin-httpclient/src/main/java/org/apache/shenyu/plugin/httpclient/DefaultRetryStrategy.java:116`
   - 
`shenyu-common/src/main/java/org/apache/shenyu/common/utils/UpstreamCheckUtils.java:73`
   - 
`shenyu-loadbalancer/src/main/java/org/apache/shenyu/loadbalancer/entity/Upstream.java:471`
   
   No implementation fix or full deployed end-to-end validation was performed 
by this review. Source-flow and runtime evidence are distinguished above.
   


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