-
Notifications
You must be signed in to change notification settings - Fork 31
Handle exceptions when resetting streams after writing to the network #1696
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
Conversation
ab60655 to
2bf7173
Compare
|
|
Hi @Ndiritu Thanks, |
|
Hi @Ndiritu |
@ihudedi the In this case, the error handling works as expected by bubbling up the exception to a developer's application. |
|
Hi @Ndiritu |



We added the
isOneShot()check to ensure that rewindable request body streams are reset after writing them e.g. after request body is written to a logging interceptor. Previously, a logging interceptor would drain the request body stream causing the network call to have an empty body.However, we didn't handle the failure scenarios of
reset()according to the docsThis PR makes a best effort measure to prevent draining the request body by an interceptor before the final network request.
If a positive content length is available, we
mark()the start of the stream with the entire stream's content length as the read limit.If during the
sink.writeAll()a newmark()is set causing thereset()to fail, we log the exception but don't fail the entire request.We do not fail the entire request in case the first call to
reset()happens during the network call.closes microsoftgraph/msgraph-sdk-java#2245
Existing unit tests for the various stream scenarios still pass