Skip to content

Commit

Permalink
meta get remote meta compatible with empty map
Browse files Browse the repository at this point in the history
  • Loading branch information
liangwei3 committed Apr 8, 2024
1 parent 3115d01 commit adcf990
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion meta/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var (
dynamicMeta = core.NewStringMap(30)
envMeta = make(map[string]string)
envPrefix = core.DefaultMetaPrefix
metaEmptyMap = make(map[string]string)
metaCache = cache.New(time.Second*time.Duration(defaultCacheExpireSecond), 30*time.Second)
notSupportCache = cache.New(time.Second*time.Duration(notSupportCacheExpireSecond), 30*time.Second)
ServiceNotSupportError = errors.New(core.ServiceNotSupport)
Expand Down Expand Up @@ -152,7 +153,12 @@ func getRemoteDynamicMeta(cacheKey string, endpoint core.EndPoint) (map[string]s
if err != nil {
return nil, err
}
return resp.GetValue().(map[string]string), nil
// multiple serialization might encode empty map into interface{}, not map[string]string
// in this case, return a public empty string map
if res, ok := resp.GetValue().(map[string]string); ok && res != nil {
return res, nil
}
return metaEmptyMap, nil
}

func getMetaServiceRequest() core.Request {
Expand Down

0 comments on commit adcf990

Please sign in to comment.