From bc62fd5b634ef7c22522f5ba3399135609ea4065 Mon Sep 17 00:00:00 2001 From: Whit Waldo Date: Sun, 6 Oct 2024 02:29:53 -0500 Subject: [PATCH 1/2] Added fix to handle null return values Signed-off-by: Whit Waldo --- src/Dapr.Client/DaprClientGrpc.cs | 15 +++++++++++---- src/Dapr.Client/DaprMetadata.cs | 1 - 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Dapr.Client/DaprClientGrpc.cs b/src/Dapr.Client/DaprClientGrpc.cs index af245afc3..84d0a1117 100644 --- a/src/Dapr.Client/DaprClientGrpc.cs +++ b/src/Dapr.Client/DaprClientGrpc.cs @@ -2390,10 +2390,17 @@ public override async Task 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(), + response.ExtendedMetadata?.ToDictionary(c => c.Key, c => c.Value) ?? + new Dictionary(), + response.RegisteredComponents?.Select(c => + new DaprComponentsMetadata(c.Name, c.Type, c.Version, c.Capabilities.ToArray())).ToList() ?? + new List()); } catch (RpcException ex) { diff --git a/src/Dapr.Client/DaprMetadata.cs b/src/Dapr.Client/DaprMetadata.cs index a58707c99..4cd812e04 100644 --- a/src/Dapr.Client/DaprMetadata.cs +++ b/src/Dapr.Client/DaprMetadata.cs @@ -11,7 +11,6 @@ // limitations under the License. // ------------------------------------------------------------------------ -using System; using System.Collections.Generic; namespace Dapr.Client From c24a0828cd847e0e27e85d5c5d17263a9de197e1 Mon Sep 17 00:00:00 2001 From: Whit Waldo Date: Fri, 11 Oct 2024 01:47:37 -0500 Subject: [PATCH 2/2] Removed unnecessary null check Signed-off-by: Whit Waldo --- src/Dapr.Client/DaprClientGrpc.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Dapr.Client/DaprClientGrpc.cs b/src/Dapr.Client/DaprClientGrpc.cs index 84d0a1117..a5f5833a2 100644 --- a/src/Dapr.Client/DaprClientGrpc.cs +++ b/src/Dapr.Client/DaprClientGrpc.cs @@ -2390,9 +2390,6 @@ public override async Task GetMetadataAsync(CancellationToken canc try { var response = await client.GetMetadataAsync(new Autogenerated.GetMetadataRequest(), options); - 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(),