Skip to content

Commit 529e367

Browse files
fix null issues
1 parent 5fb96b1 commit 529e367

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

src/services/live/Codebreaker.Live/Endpoints/StreamingLiveHub.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
using Azure.Messaging.EventHubs.Consumer;
22

3-
using Microsoft.Extensions.Azure;
4-
53
using System.Runtime.CompilerServices;
64

75
namespace Codebreaker.Live.Endpoints;
@@ -12,11 +10,16 @@ public async IAsyncEnumerable<GameSummary> SubscribeToGameCompletions(string gam
1210
{
1311
await foreach (PartitionEvent ev in consumerClient.ReadEventsAsync(cancellationToken))
1412
{
15-
GameSummary gameSummary;
13+
GameSummary? gameSummary;
1614
try
1715
{
1816
logger.ProcessingGameCompletionEvent();
1917
gameSummary = ev.Data.EventBody.ToObjectFromJson<GameSummary>();
18+
if (gameSummary is null)
19+
{
20+
logger.GameSummaryIsNull();
21+
continue;
22+
}
2023
}
2124
catch (Exception ex)
2225
{

src/services/ranking/Codebreaker.Ranking/Services/GameSummaryEventProcessor.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ public async Task StartProcessingAsync(CancellationToken cancellationToken = def
1515
{
1616
logger.LogInformation("Processing event");
1717

18-
GameSummary summary = args.Data.EventBody.ToObjectFromJson<GameSummary>();
18+
GameSummary? summary = args.Data.EventBody.ToObjectFromJson<GameSummary>();
19+
20+
if (summary is null)
21+
{
22+
logger.LogWarning("Game summary is empty after deserialization");
23+
return;
24+
}
1925

2026
logger.LogInformation("Received game completion event for game {gameId}", summary.Id);
2127
using var context = await factory.CreateDbContextAsync(cancellationToken);

0 commit comments

Comments
 (0)