Merge pull request #1353 from WhitWaldo/get-metadata-fix

Added fix to handle null return values from GetMetadataAsync
This commit is contained in:
Whit Waldo 2024-10-11 01:57:52 -05:00 committed by GitHub
commit 19cb481557
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 5 deletions

View File

@ -2390,10 +2390,14 @@ namespace Dapr.Client
try
{
var response = await client.GetMetadataAsync(new Autogenerated.GetMetadataRequest(), options);
return new DaprMetadata(response.Id,
response.ActorRuntime.ActiveActors.Select(c => new DaprActorMetadata(c.Type, c.Count)).ToList(),
response.ExtendedMetadata.ToDictionary(c => c.Key, c => c.Value),
response.RegisteredComponents.Select(c => new DaprComponentsMetadata(c.Name, c.Type, c.Version, c.Capabilities.ToArray())).ToList());
return new DaprMetadata(response.Id ?? "",
response.ActorRuntime?.ActiveActors?.Select(c => new DaprActorMetadata(c.Type, c.Count)).ToList() ??
new List<DaprActorMetadata>(),
response.ExtendedMetadata?.ToDictionary(c => c.Key, c => c.Value) ??
new Dictionary<string, string>(),
response.RegisteredComponents?.Select(c =>
new DaprComponentsMetadata(c.Name, c.Type, c.Version, c.Capabilities.ToArray())).ToList() ??
new List<DaprComponentsMetadata>());
}
catch (RpcException ex)
{

View File

@ -11,7 +11,6 @@
// limitations under the License.
// ------------------------------------------------------------------------
using System;
using System.Collections.Generic;
namespace Dapr.Client