You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the reponse payload was empty, I get the Exception:
System.ObjectDisposedException: The current buffer has already been disposed
at the point where Memory is accessed. Which is confusing.
This seems to be because NatsMemoryOwner treats a null _array as having been disposed. But in NatsMsg<T>.Build, an empty payload causes the NatsMemoryOwner to be created as default, which I would assume has null for the value of _array:
When decoding an empty payload, I would expect the NatsMemoryOwner<byte> to be the equivalent of an empty array. I would only expect an ObjectDisposedException if the struct had previously been disposed.
Server and client version
Client version 2.0.2
Host environment
No response
Steps to reproduce
Decode a message with empty payload as NatsMemoryOwner<byte>.
The text was updated successfully, but these errors were encountered:
But that was after way too much time spent trying to work out how the NatsMemoryOwner had been disposed before I used it! The only way I worked it out in the end was by going through the Nats client source code. I'm just trying to save others from my pain :)
But that was after way too much time spent trying to work out how the NatsMemoryOwner had been disposed before I used it! The only way I worked it out in the end was by going through the Nats client source code. I'm just trying to save others from my pain :)
No you're absolutely right. I'm looking into it. just wanted to note a workaround now before we released a fix.
thank you for the detailed reports btw. very helpful 👍
Observed behavior
When trying to access the memory for NatsMemoryOwner like:
If the reponse payload was empty, I get the Exception:
at the point where
Memory
is accessed. Which is confusing.This seems to be because
NatsMemoryOwner
treats a null_array
as having been disposed. But inNatsMsg<T>.Build
, an empty payload causes theNatsMemoryOwner
to be created asdefault
, which I would assume hasnull
for the value of_array
:Expected behavior
When decoding an empty payload, I would expect the
NatsMemoryOwner<byte>
to be the equivalent of an empty array. I would only expect anObjectDisposedException
if the struct had previously been disposed.Server and client version
Client version 2.0.2
Host environment
No response
Steps to reproduce
Decode a message with empty payload as
NatsMemoryOwner<byte>
.The text was updated successfully, but these errors were encountered: