Alanxtl commented on code in PR #3282:
URL: https://github.com/apache/dubbo-go/pull/3282#discussion_r3005702769


##########
common/url.go:
##########
@@ -653,9 +661,29 @@ func (c *URL) GetNonDefaultParam(s string) (string, bool) {
        return r, r != ""
 }
 
-// GetParams gets values
+// GetParams gets values.
+// Deprecated: use CopyParams instead.
 func (c *URL) GetParams() url.Values {
-       return c.params
+       return c.CopyParams()
+}
+
+// CopyParams returns a deep copy of params.
+func (c *URL) CopyParams() url.Values {
+       c.paramsLock.RLock()
+       defer c.paramsLock.RUnlock()
+
+       if c.params == nil {
+               return nil
+       }
+
+       params := make(url.Values, len(c.params))
+       for k, vs := range c.params {
+               copied := make([]string, len(vs))
+               copy(copied, vs)
+               params[k] = copied
+       }
+
+       return params
 }
 

Review Comment:
   cool



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

Reply via email to