Copilot commented on code in PR #2941:
URL: https://github.com/apache/dubbo-go/pull/2941#discussion_r2184478592


##########
client/options.go:
##########
@@ -543,6 +543,21 @@ func (cliOpts *ClientOptions) init(opts ...ClientOption) 
error {
        }
 
        // todo(DMwangnima): is there any part that we should do compatibility 
processing?
+       // init overallReference from Consumer config
+       if consumerConf != nil {

Review Comment:
   Consider checking and initializing `cliOpts.overallReference` before 
dereferencing it to avoid a nil pointer panic when `overallReference` is unset.



##########
client/options.go:
##########
@@ -543,6 +543,21 @@ func (cliOpts *ClientOptions) init(opts ...ClientOption) 
error {
        }
 
        // todo(DMwangnima): is there any part that we should do compatibility 
processing?
+       // init overallReference from Consumer config
+       if consumerConf != nil {
+               if cliOpts.overallReference.Filter == "" {
+                       cliOpts.overallReference.Filter = consumerConf.Filter
+               }
+               if len(cliOpts.overallReference.RegistryIDs) <= 0 {
+                       cliOpts.overallReference.RegistryIDs = 
consumerConf.RegistryIDs
+               }
+               if cliOpts.overallReference.TracingKey == "" {
+                       cliOpts.overallReference.TracingKey = 
consumerConf.TracingKey
+               }
+               if cliOpts.overallReference.Check == nil {
+                       cliOpts.overallReference.Check = &consumerConf.Check

Review Comment:
   [nitpick] Allocating the pointer to `consumerConf.Check` directly ties the 
two structs; consider copying the bool into a new variable (e.g., `val := 
consumerConf.Check; cliOpts.overallReference.Check = &val`) to avoid unintended 
side effects.
   ```suggestion
                        val := consumerConf.Check
                        cliOpts.overallReference.Check = &val
   ```



-- 
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: notifications-unsubscr...@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org
For additional commands, e-mail: notifications-h...@dubbo.apache.org

Reply via email to