Skip to content

Commit a7c3af8

Browse files
committed
fixes flaky check in samples
Signed-off-by: Oleh Dokuka <[email protected]>
1 parent 493b5cc commit a7c3af8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

RSocketSample/ProtobufNetSerializer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ public static class ProtobufNetSerializer
88
{
99
static public ReadOnlySequence<byte> Serialize<T>(in T item)
1010
{
11-
if (item == default) { return default; }
11+
if (item == null) { return default; }
1212
using (var stream = new MemoryStream()) //According to source, access to the buffer is safe after disposal (See. Dispose()): https://github.com/dotnet/coreclr/blob/master/src/System.Private.CoreLib/shared/System/IO/MemoryStream.cs#L133
1313
{
1414
ProtoBuf.Serializer.Serialize(stream, item); //TODO Probably need a Stream -> IBufferWriter. I think the .NET folks have made one...
1515
if (stream.TryGetBuffer(out var buffer))
1616
{
1717
var seq = new ReadOnlySequence<byte>(buffer.Array, buffer.Offset, buffer.Count);
1818

19-
return new ReadOnlySequence<byte>(stream.ToArray()); //TODO not great, but the stream is disposing, so we'd lose the buffer.
19+
return new ReadOnlySequence<byte>(stream.ToArray()); //TODO not great, but the stream is disposing, so we'd lose the buffer.
2020
}
2121
else { throw new InvalidOperationException("Unable to get MemoryStream buffer"); }
2222
}

0 commit comments

Comments
 (0)