mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-15 00:15:15 +08:00
Resolve ConvertPayloadToString resulting in ArgumentNullException (#1745)
Resolve breaking change where previously ConvertPayloadToString returned null if the payload was null
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
using MQTTnet.Internal;
|
||||
|
||||
namespace MQTTnet
|
||||
{
|
||||
@@ -16,6 +17,11 @@ namespace MQTTnet
|
||||
throw new ArgumentNullException(nameof(applicationMessage));
|
||||
}
|
||||
|
||||
if(applicationMessage.PayloadSegment == EmptyBuffer.ArraySegment)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var payloadSegment = applicationMessage.PayloadSegment;
|
||||
return Encoding.UTF8.GetString(payloadSegment.Array, payloadSegment.Offset, payloadSegment.Count);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user