Skip to content

Commit

Permalink
Added fix to handle null return values
Browse files Browse the repository at this point in the history
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
  • Loading branch information
WhitWaldo committed Oct 6, 2024
1 parent 74f6b01 commit bc62fd5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
15 changes: 11 additions & 4 deletions src/Dapr.Client/DaprClientGrpc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2390,10 +2390,17 @@ 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());
if (response is null)
return null;

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 bc62fd5

Please sign in to comment.