XnLemon commented on code in PR #3395:
URL: https://github.com/apache/dubbo-go/pull/3395#discussion_r3401456985


##########
registry/servicediscovery/service_instances_changed_listener_impl.go:
##########
@@ -258,20 +263,61 @@ func GetMetadataInfo(app string, instance 
registry.ServiceInstance, revision str
        var metadataInfo *info.MetadataInfo
        var err error
        if instance.GetMetadata() == nil {
+               // No metadata map at all; treat as default (local/RPC) storage 
type.
                metadataStorageType = constant.DefaultMetadataStorageType
        } else {
                metadataStorageType = 
instance.GetMetadata()[constant.MetadataStorageTypePropertyName]
+               if metadataStorageType == "" {
+                       // MetadataStorageTypePropertyName absent (e.g. old 
Java provider); default to local storage type.
+                       logger.Warnf("[Metadata] MetadataStorageType not set 
for instance %s, defaulting to local", instance.GetID())
+                       metadataStorageType = 
constant.DefaultMetadataStorageType
+               }
        }
+
        if metadataStorageType == constant.RemoteMetadataStorageType {
-               metadataInfo, err = 
metadata.GetMetadataFromMetadataReport(revision, instance, registryId)
-               if err != nil {
-                       return nil, err
+               var reportErr error
+               metadataInfo, reportErr = 
metadata.GetMetadataFromMetadataReport(revision, instance, registryId)
+               if reportErr == nil && metadataInfo != nil {
+                       metaCache.Set(cacheKey, metadataInfo)
+                       return metadataInfo, nil
                }
-       } else {
+               if reportErr != nil {
+                       logger.Errorf("[Metadata-Fallback] report failed, 
fallback to RPC app=%s registry=%s revision=%s err=%v",
+                               app, registryId, revision, reportErr)
+               } else {
+                       logger.Warnf("[Metadata-Fallback] report returned nil 
metadata, fallback to RPC app=%s registry=%s revision=%s",
+                               app, registryId, revision)
+               }

Review Comment:
   applied



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