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

Fix MultiJson when direct streaming is disabled #149

Merged
merged 1 commit into from
Dec 19, 2024

Conversation

dawust
Copy link
Contributor

@dawust dawust commented Dec 11, 2024

When writing data using PostData.MultiJson, the FinishStream method is incorrectly duplicating data into the same buffer when disableDirectStreaming is set to true. This happens because BufferIfNeeded modifies writableStream by reference to use a newly created MemoryStream buffer, but FinishStream later uses the same writableStream (now the buffer) for copying, resulting in self-copying and data duplication.

I think, the issue can be resolved by introducing a local variable stream to hold the current writing stream, ensuring that the original writableStream remains distinct from the buffer. The local stream is used for writing data, while the original writableStream is used correctly in FinishStream.

@flobernd
Copy link
Member

flobernd commented Dec 13, 2024

cc @stevejgordon Seems like a regression from our stream refactoring. Let me know if I should take care, or if you want to address it.

@stevejgordon
Copy link
Collaborator

@flobernd Yep, it sounds like the refactor missed something here. I'm unlikely to get to this until January. If you have capacity to take a look, that would be much appreciated.

@flobernd
Copy link
Member

@stevejgordon Sure 🙂 Will have a look on Monday.

Thanks @dawust for creating a PR!

@flobernd flobernd merged commit ec5f19d into elastic:main Dec 19, 2024
4 checks passed
@flobernd flobernd added bug Something isn't working v0.5.7 labels Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working v0.5.7
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants