Skip to content

Commit bcde29e

Browse files
committed
Simplify writer code, and throw an exception if the unthinkable happens
1 parent 4d8fff1 commit bcde29e

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

projects/RabbitMQ.Client/client/impl/SocketFrameHandler.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,16 +250,15 @@ public bool TryReadFrame(out InboundFrame frame)
250250

251251
public void SendHeader()
252252
{
253-
#if NET
254-
_pipeWriter.AsStream().Write(ProtocolHeader);
255-
#else
256-
_pipeWriter.AsStream().Write(ProtocolHeader.ToArray(), 0, ProtocolHeader.Length);
257-
#endif
253+
_pipeWriter.Write(ProtocolHeader);
258254
}
259255

260256
public void Write(ReadOnlyMemory<byte> memory)
261257
{
262-
_channelWriter.TryWrite(memory);
258+
if (!_channelWriter.TryWrite(memory))
259+
{
260+
throw new ApplicationException("Please report this bug here: https://github.com/rabbitmq/rabbitmq-dotnet-client/issues");
261+
}
263262
}
264263

265264
private async Task WriteLoop()

0 commit comments

Comments
 (0)