From 215fc558f9c96245bd4b3779178f03114336dc72 Mon Sep 17 00:00:00 2001 From: Norm Johanson Date: Sun, 20 Oct 2024 15:02:24 -0700 Subject: [PATCH] Add null checks before attempting debug response writing --- .../Amazon.Lambda.Serialization.Json.csproj | 2 +- .../src/Amazon.Lambda.Serialization.Json/JsonSerializer.cs | 2 +- .../AbstractLambdaJsonSerializer.cs | 2 +- .../Amazon.Lambda.Serialization.SystemTextJson.csproj | 2 +- .../LambdaJsonSerializer.cs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Libraries/src/Amazon.Lambda.Serialization.Json/Amazon.Lambda.Serialization.Json.csproj b/Libraries/src/Amazon.Lambda.Serialization.Json/Amazon.Lambda.Serialization.Json.csproj index 1090ea808..803e971b0 100644 --- a/Libraries/src/Amazon.Lambda.Serialization.Json/Amazon.Lambda.Serialization.Json.csproj +++ b/Libraries/src/Amazon.Lambda.Serialization.Json/Amazon.Lambda.Serialization.Json.csproj @@ -9,7 +9,7 @@ Amazon.Lambda.Serialization.Json Amazon.Lambda.Serialization.Json AWS;Amazon;Lambda - 2.2.3 + 2.2.4 diff --git a/Libraries/src/Amazon.Lambda.Serialization.Json/JsonSerializer.cs b/Libraries/src/Amazon.Lambda.Serialization.Json/JsonSerializer.cs index 77c23e1e6..0555e2f9c 100644 --- a/Libraries/src/Amazon.Lambda.Serialization.Json/JsonSerializer.cs +++ b/Libraries/src/Amazon.Lambda.Serialization.Json/JsonSerializer.cs @@ -94,7 +94,7 @@ public void Serialize(T response, Stream responseStream) { try { - if (debug) + if (debug && response != null) { using (StringWriter debugWriter = new StringWriter()) { diff --git a/Libraries/src/Amazon.Lambda.Serialization.SystemTextJson/AbstractLambdaJsonSerializer.cs b/Libraries/src/Amazon.Lambda.Serialization.SystemTextJson/AbstractLambdaJsonSerializer.cs index 0f27cf3fa..2656c535b 100644 --- a/Libraries/src/Amazon.Lambda.Serialization.SystemTextJson/AbstractLambdaJsonSerializer.cs +++ b/Libraries/src/Amazon.Lambda.Serialization.SystemTextJson/AbstractLambdaJsonSerializer.cs @@ -48,7 +48,7 @@ public void Serialize(T response, Stream responseStream) { try { - if (_debug) + if (_debug && response != null) { using (var debugStream = new MemoryStream()) using (var utf8Writer = new Utf8JsonWriter(debugStream, WriterOptions)) diff --git a/Libraries/src/Amazon.Lambda.Serialization.SystemTextJson/Amazon.Lambda.Serialization.SystemTextJson.csproj b/Libraries/src/Amazon.Lambda.Serialization.SystemTextJson/Amazon.Lambda.Serialization.SystemTextJson.csproj index e6cb09dd6..84dfc7a7e 100644 --- a/Libraries/src/Amazon.Lambda.Serialization.SystemTextJson/Amazon.Lambda.Serialization.SystemTextJson.csproj +++ b/Libraries/src/Amazon.Lambda.Serialization.SystemTextJson/Amazon.Lambda.Serialization.SystemTextJson.csproj @@ -9,7 +9,7 @@ Amazon.Lambda.Serialization.SystemTextJson Amazon.Lambda.Serialization.SystemTextJson AWS;Amazon;Lambda - 2.4.3 + 2.4.4 README.md diff --git a/Libraries/src/Amazon.Lambda.Serialization.SystemTextJson/LambdaJsonSerializer.cs b/Libraries/src/Amazon.Lambda.Serialization.SystemTextJson/LambdaJsonSerializer.cs index bc162f227..dae777b54 100644 --- a/Libraries/src/Amazon.Lambda.Serialization.SystemTextJson/LambdaJsonSerializer.cs +++ b/Libraries/src/Amazon.Lambda.Serialization.SystemTextJson/LambdaJsonSerializer.cs @@ -95,7 +95,7 @@ public void Serialize(T response, Stream responseStream) { try { - if (_debug) + if (_debug && response != null) { using (var debugWriter = new StringWriter()) using (var utf8Writer = new Utf8JsonWriter(responseStream, WriterOptions))