onceMisery opened a new pull request, #16133: URL: https://github.com/apache/dubbo/pull/16133
## What is the purpose of the change? This PR fixes a regression introduced while addressing [#16108](https://github.com/apache/dubbo/issues/16108). ### Background During the #16108 fix, URL de-duplication in `ServiceDiscoveryRegistryDirectory#refreshInvoker()` was accidentally removed. If registry sends duplicated instance URLs in one notification batch, `toInvokers()` may call `protocol.refer()` multiple times for the same endpoint before map finalization. The later `put()` overwrites earlier entries in `newUrlInvokerMap`, which can leave previously created invokers untracked and not destroyed. This regresses the behavior fixed by commit `a35af2742a` (`Remove duplicated invokers in registry notification`). ### What is changed 1. Restore invoker URL de-duplication in `refreshInvoker()` - Re-introduce `invokerUrls.stream().distinct()` before `toInvokers()`. - Keep duplicate-notification log with original vs distinct size. 2. Keep #16108 logic correction - Spring Cloud instance matching now requires consumer protocol to be explicitly `rest`. - Avoid matching Spring Cloud instances when consumer protocol is `null` or non-REST. 3. Add regression test coverage - `SpringCloudServiceInstanceNotificationCustomizerTest` verifies protocol-match behavior and mixed-instance handling. - `ServiceDiscoveryRegistryDirectoryTest` verifies duplicated URLs in one notify batch are de-duplicated and do not trigger repeated refer flow. ### Why this is needed - Prevents duplicate refer calls and potential invoker leak in duplicate-notification scenarios. - Preserves the intended #16108 behavior without regressing prior duplicate-notification safety. - Adds tests to prevent future regressions. ## GitHub Issue - Fixes/relates to: [#16108](https://github.com/apache/dubbo/issues/16108) ## Checklist - [x] Make sure there is a [GitHub_issue](https://github.com/apache/dubbo/issues) field for the change. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit-test to verify your logic correction. If the new feature or significant change is committed, please remember to add sample in [dubbo samples](https://github.com/apache/dubbo-samples) project. - [x] Make sure gitHub actions can pass. [Why the workflow is failing and how to fix it?](../CONTRIBUTING.md) -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
