-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
Should connection.disconnect() be called normally? #702
Comments
@wmulligan don't call disconnect until you're done with the connection. You can call it when you're done with the connection; it doesn't harm connection pooling or anything unless the disconnect is abrupt. |
Just to confirm, when we call getInputStream() and receive the inputstream, has the entire response body been buffered/received? Or is the input stream a live stream from the server that will block when we read it? |
You shouldn't call |
Alright thanks for the reply. One more question, what happens if we don't call disconnect()? Will the connection still be recycled without calling disconnect? Why I am asking these questions is b/c we make network calls on one thread, and do parsing on another thread, so I am trying to figure out how to pass the inputStream to the parser, while not killing the connection. If we don't need to call disconnect, then that would solve the issue. |
You don't need to call disconnect. You do need to close the input stream containing the response body. |
I am looking at your latest 1.5.4 changes.
Should we be calling HttpUrlConnection.disconnect after every request? The documentation is a bit vague about this.
When we call disconnect(), what happens if we have not read the entire response body yet? Is it possible that we could lose part of the response if we call disconnect() direct after getInputStream()?
Thanks!
The text was updated successfully, but these errors were encountered: