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

   ### What changed
   
   Close #6522
   
   ### Problem
   
   `buildHandle` in the divide / dubbo / grpc / tars client register services 
detects status-only changes into `diffStatusList`, but never applies them to 
`existList` — the upstream `equals()` methods compare identity fields only 
(host, protocol, url,
   namespaceId), so a status-changed upstream is still treated as an existing 
one and keeps its old status. `existList` is then serialized back into the 
selector handle, so the change is lost.
   
   Reproduce: register an upstream with `status=true`, then send a DELETED 
event for it. The change is detected but the DB selector handle still holds 
`status=true`.
   
   This is always hit with the default `shenyu.upstream.check=false`, where the 
handle is written purely from `buildHandle`'s return value. With health check 
enabled the path is masked by `UpstreamCheckService.updateSelectorHandler`.
   
   Note: the issue lists dubbo/grpc/tars; 
`ShenyuClientRegisterDivideServiceImpl` shares the same code and is fixed as 
well.
   
   ### Fix
   
   Add `syncUpstreamStatus(existList, diffStatusList)` to 
`AbstractShenyuClientRegisterServiceImpl` and call it from the four 
implementations, writing the new status back onto the matching entry in 
`existList`. No change to `equals()`/`hashCode()` — those are relied on by 
`UPSTREAM_MAP`, `ZOMBIE_SET` and the `removeAll` paths.
   
   Going back online is symmetric: the client re-registers with `status=true`, 
`diffStatusList` matches again and `existList` is restored.
   
   ### Tests
   
   Added `testBuildHandleWithStatusChanged` to the four register service tests: 
a handle holding two live upstreams plus a DELETED event for one of them must 
yield `status=false` for that node and `status=true` for the other, with the 
list size unchanged. All four fail without the production change.
   
   `mvn test -pl shenyu-admin` (4 classes, 28 cases) and `mvn checkstyle:check` 
pass.
   
   - [x] You have read the [contribution 
guidelines](https://shenyu.apache.org/community/contributor-guide).
   - [ ] 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