Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serialization: Stack<T> is deserialized in reversed order #8766

Closed
DmitryZhelnin opened this issue Dec 12, 2023 · 2 comments · Fixed by #8768
Closed

Serialization: Stack<T> is deserialized in reversed order #8766

DmitryZhelnin opened this issue Dec 12, 2023 · 2 comments · Fixed by #8768

Comments

@DmitryZhelnin
Copy link

Consider following example:

public class MyGrain : IMyGrain
{
    public Task<Stack<int>> GetStack()
    {
        var stack = new Stack<int>();
        stack.Push(1);
        stack.Push(2);
        stack.Push(3);
        stack.Push(4);
        return Task.FromResult(stack);
    }
}

And the calling code:

var stack = await myGrain.GetStack();
var value = stack.Pop(); // returns 1

Here in StackCodec during deserealization process values from original stack are just pushed to the new stack what makes the order to be reversed.

result.Push(_fieldCodec.ReadValue(ref reader, header));

@ReubenBond
Copy link
Member

Thank you for reporting. I've opened #8768 with a fix + test.

@ReubenBond
Copy link
Member

I've opened #8769 to ensure that this does not happen again.

@github-actions github-actions bot locked and limited conversation to collaborators Jan 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants