Skip to content

Commit

Permalink
Merge pull request #1353 from WhitWaldo/get-metadata-fix
Browse files Browse the repository at this point in the history
Added fix to handle null return values from GetMetadataAsync
  • Loading branch information
WhitWaldo authored Oct 11, 2024
2 parents c47e650 + c24a082 commit 19cb481
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/Dapr.Client/DaprClientGrpc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2390,10 +2390,14 @@ public override async Task<DaprMetadata> GetMetadataAsync(CancellationToken canc
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)
{
Expand Down
1 change: 0 additions & 1 deletion src/Dapr.Client/DaprMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
// limitations under the License.
// ------------------------------------------------------------------------

using System;
using System.Collections.Generic;

namespace Dapr.Client
Expand Down

0 comments on commit 19cb481

Please sign in to comment.