Skip to content

Commit

Permalink
Add null checks before attempting debug response writing
Browse files Browse the repository at this point in the history
  • Loading branch information
normj committed Oct 20, 2024
1 parent d0a84f2 commit 02eb5b4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void Serialize<T>(T response, Stream responseStream)
{
try
{
if (debug)
if (debug && response != null)
{
using (StringWriter debugWriter = new StringWriter())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void Serialize<T>(T response, Stream responseStream)
{
try
{
if (_debug)
if (_debug && response != null)
{
using (var debugStream = new MemoryStream())
using (var utf8Writer = new Utf8JsonWriter(debugStream, WriterOptions))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void Serialize<T>(T response, Stream responseStream)
{
try
{
if (_debug)
if (_debug && response != null)
{
using (var debugWriter = new StringWriter())
using (var utf8Writer = new Utf8JsonWriter(responseStream, WriterOptions))
Expand Down

0 comments on commit 02eb5b4

Please sign in to comment.