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

Add documentation to clarify if ResponseBody.close() is necessary #3400

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tejas-n
Copy link

@tejas-n tejas-n commented May 24, 2020

Closes #2950, closes #2929

@tejas-n tejas-n force-pushed the responsebody-close-docs branch from c2500ca to 3e6572f Compare May 24, 2020
/**
* The deserialized response body of a {@linkplain #isSuccessful() successful} response.
*
* <p>If the body is of type {@link ResponseBody}, calling {@link ResponseBody#close close} is
Copy link
Member

@swankjesse swankjesse May 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is helpful because it splits the type system.

By following this doc you need to differentiate between responses that are created from streaming endpoints and responses that are not. If you write general purpose code to accept a Response, you need to clarify whether it's a streaming one. Also if you add @Streaming you create a resource leak.

It's simpler and more resilient to document that this must be closed under all circumstances.

Copy link
Author

@tejas-n tejas-n May 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the reply. Yeah, that makes sense. So you are suggesting "If the body is of type ResponseBody, close() should always be called to avoid leaking resources"? Am I correct?

Copy link
Author

@tejas-n tejas-n May 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@swankjesse I've updated the PR, can you let me know if that looks correct, please?

@tejas-n tejas-n force-pushed the responsebody-close-docs branch from 3e6572f to 5dd32be Compare May 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants