nanjiek commented on code in PR #2942:
URL: https://github.com/apache/dubbo-go/pull/2942#discussion_r2249948153


##########
registry/directory/directory.go:
##########
@@ -575,14 +576,27 @@ type consumerConfigurationListener struct {
        directory *RegistryDirectory
 }
 
-func newConsumerConfigurationListener(dir *RegistryDirectory) 
*consumerConfigurationListener {
+func newConsumerConfigurationListener(dir *RegistryDirectory, url *common.URL) 
*consumerConfigurationListener {
        listener := &consumerConfigurationListener{directory: dir}
+
+       // TODO: Temporary compatibility with old APIs, can be removed later
        application := config.GetRootConfig().Application
        listener.InitWith(
                application.Name+constant.ConfiguratorSuffix,
                listener,
                extension.GetDefaultConfiguratorFunc(),
        )
+
+       if ApplicationConfRaw, ok := url.GetAttribute(constant.ApplicationKey); 
ok {

Review Comment:
   I set the Attribute in the directory_test. What's more, if the application 
config doesn't exsit in the url, the code will use the DefaultApplicationConfig 
of global.
   
        applicationConfig := &global.ApplicationConfig{
                Name: "test-application",
        }
   
        url, _ := common.NewURL("mock://127.0.0.1:1111",
                common.WithAttribute(constant.ApplicationKey, 
applicationConfig),
        )
   
   if _, ok := url.GetAttribute(constant.ApplicationKey); !ok {
   
                application := config.GetRootConfig().Application
                if application == nil {
                        defaultAppConfig := global.DefaultApplicationConfig()
                        url.SetAttribute(constant.ApplicationKey, 
defaultAppConfig)
                }
        }
   
   



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