-
Notifications
You must be signed in to change notification settings - Fork 606
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
test: fix flaky test by buffering possibly chunked content #17923
Conversation
abc9afe
to
add2678
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the reason it's flaky is because it's a race condition between the HTTP handling completing and Jackson finishing the deserialization and closing the InputStream
. From BodySubscribers.ofInputStream()
:
To ensure that all resources associated with the corresponding exchange are properly released the caller must ensure to either read all bytes until EOF is reached, or call InputStream. close if it is unable or unwilling to do so. Calling close before exhausting the stream may cause the underlying HTTP connection to be closed and prevent it from being reused for subsequent operations.
I don't think Jackson waits for EOF necessarily, see FasterXML/jackson-jaxrs-providers#108 (comment)
Successfully created backport PR for |
Successfully created backport PR for |
Successfully created backport PR for |
Successfully created backport PR for |
Description
This PR attempts to fix a flaky test which looks to be caused by the interaction of Jackson and the underlying body subscriber.
The error was previously: https://github.com/camunda/zeebe/actions/runs/8846555512/job/24292686857
From it, we can see that the body subscriber (which is an
InputStream
) ends up getting closed by Jackson. On close, it will cancel the subscription. On cancelling, it will run its action, which callsonReadError
with theIOException
containing thesubscription cancelled
message.The question for me here is, why is this not happening every time? Why is it flaky? 🤔
At any rate, I think we can just work around this by simply changing the underlying subscriber to
ofByteArray
, which will buffer the complete response first. This response tends to be small anyway, and this is only for a test.