Skip to content

Disconnect HttpURLConnection in HTTPStreamLoader to fix connection leak - #775

Open
Quaden2307 wants to merge 2 commits into
Netflix:2.xfrom
Quaden2307:fix/768-httpstreamloader-disconnect
Open

Quaden2307 wants to merge 2 commits into
Netflix:2.xfrom
Quaden2307:fix/768-httpstreamloader-disconnect

Conversation

@Quaden2307

Copy link
Copy Markdown

Fixes #768

HTTPStreamLoader.call() opened an HttpURLConnection but never called disconnect(), leaking a connection on every poll. This change wraps the request in a try/finally block so that disconnect() always runs. It also reads the response into memory and returns a ByteArrayInputStream, so the connection can be closed before returning. The input stream, including the gzip wrapper, is also now closed automatically after reading.

Also adds HTTPStreamLoaderTest, the first tests for this class, covering 200, gzip, 304 and 500.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Security: HTTPStreamLoader never calls HttpURLConnection.disconnect() — connection leak (CWE-772)

1 participant