phpcyy opened a new pull request, #3160: URL: https://github.com/apache/dubbo-go/pull/3160
This commit fixes a critical thread-safety issue in the Clone and CloneExceptParams methods of the URL struct. The previous implementation used the github.com/jinzhu/copier library, which is not safe for types containing mutexes. This caused two main problems in a concurrent environment: 1. Data Races: The library read fields from the source URL without acquiring a lock, leading to data races. 2. Mutex Copying: The sync.RWMutex fields within the URL were being copied, which is an incorrect usage of mutexes and leads to unpredictable behavior. The implementation has been refactored to manually construct a new URL instance and explicitly copy each field. This new approach ensures that a cloned URL has its own new, properly initialized mutexes, making the cloning operation safe for concurrent use. This also has the added benefit of removing the copier dependency. ### Description Fixes #3159 ### Checklist - [x] I confirm the target branch is `develop` - [x] Code has passed local testing - [x] I have added tests that prove my fix is effective or that my feature works -- 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]
