AsperforMias commented on code in PR #3481:
URL: https://github.com/apache/dubbo-go/pull/3481#discussion_r3551713488


##########
dubbo.go:
##########
@@ -61,6 +62,39 @@ func NewInstance(opts ...InstanceOption) (*Instance, error) {
        return &Instance{insOpts: newInsOpts}, nil
 }
 
+// GetOptionsSnapshot returns a detached snapshot of this instance's options.
+func (ins *Instance) GetInstanceOptionsSnapshot() *InstanceOptions {
+       if ins == nil || ins.insOpts == nil {
+               return nil
+       }
+       return ins.insOpts.Clone()
+}
+
+// GetCustomConfig returns a detached snapshot of this instance's custom 
config.
+func (ins *Instance) GetCustomConfigSnapshot() *global.CustomConfig {
+       if ins == nil || ins.insOpts == nil {
+               return nil
+       }
+       return ins.insOpts.CloneCustom()

Review Comment:
   这里返回的是浅层copy,`ConfigMap` 的第一层 map 会被复制,但如果 value 是 
map/slice/pointer这几个type,内部的可变对象还是可能被共享
   感觉可以注释里明确这个copy情况,或者补一个嵌套的可变对象的 测试 什么的



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