DownloaderImpl: Auto-close resources and simplify headers setting#11969
Merged
Profpatsch merged 1 commit intoTeamNewPipe:devfrom Jan 31, 2025
Merged
DownloaderImpl: Auto-close resources and simplify headers setting#11969Profpatsch merged 1 commit intoTeamNewPipe:devfrom
Profpatsch merged 1 commit intoTeamNewPipe:devfrom
Conversation
Profpatsch
reviewed
Jan 31, 2025
The headers should be overwritten in the same way, based on how `.header` is the same as `.removeHeader().addHeader()`. We weren’t closing the request resources after using them, potentially leaking file handles. This will add autoclosing for both the request and the body objects.
Contributor
|
Good catch, we need to close the Request. I also added a try block for the body reader, which should also be closed. |
Contributor
|
Using Optional for simple null handling is a little silly in my opinion, especially cause we can convert to kotlin in the future. |
|
Profpatsch
approved these changes
Jan 31, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



What is it?
Description of the changes in your PR
executemethod to improve readability and resource management.try-with-resourcesto ensure automatic closing of theResponseobject.Optionalto handle request bodies and responses, reducing null checks.Due diligence