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

OEmbedClientImpl leaks network connections #2715

Merged
merged 6 commits into from
Apr 8, 2024
Merged

Conversation

andreeadracea
Copy link
Contributor

Using try-with-resources in order to be sure the HttpClient connection will be closed after using it.

Q                       A
Fixed Issues? Fixes #1, Fixes #2
Patch: Bug Fix?
Minor: New Feature?
Major: Breaking Change?
Tests Added + Pass? Yes
Documentation Provided NO (code comments and or markdown)
Any Dependency Changes?
License Apache License, Version 2.0

Copy link

sonarcloud bot commented Apr 8, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@andreeadracea andreeadracea merged commit 34ee437 into main Apr 8, 2024
13 checks passed
@andreeadracea andreeadracea deleted the issue/SITES-14725 branch April 8, 2024 13:00
}
HttpResponse response = httpClient.execute(new HttpGet(url));
return response.getEntity().getContent();
Copy link
Contributor

Choose a reason for hiding this comment

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

AFAIK accessing the response's input stream is no longer possible once the surrounding http client is closed.
One rather needs to deserialize it first, preferably via https://www.javadoc.io/doc/org.apache.httpcomponents/httpclient/4.3.2/org/apache/http/impl/client/CloseableHttpClient.html#execute(org.apache.http.HttpHost,%20org.apache.http.HttpRequest,%20org.apache.http.client.ResponseHandler)

Copy link
Member

Choose a reason for hiding this comment

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

@kwin , you're right! @andreeadracea , that's also why the ITs are failing:

Test Result (7 failures / +6)
    ITHttpTests.com.adobe.cq.wcm.core.components.it.http.ComponentsIT.testEmbed
    E2ESeleniumTestsGroup3.com.adobe.cq.wcm.core.components.it.seljup.tests.embed.v1.EmbedIT.testUrlOEmbedYouTube
    E2ESeleniumTestsGroup3.com.adobe.cq.wcm.core.components.it.seljup.tests.embed.v1.EmbedIT.testUrlOEmbedSoundCloud
    E2ESeleniumTestsGroup3.com.adobe.cq.wcm.core.components.it.seljup.tests.embed.v1.EmbedIT.testUrlValidation
    E2ESeleniumTestsGroup3.com.adobe.cq.wcm.core.components.it.seljup.tests.embed.v2.EmbedIT.testUrlOEmbedYouTube
    E2ESeleniumTestsGroup3.com.adobe.cq.wcm.core.components.it.seljup.tests.embed.v2.EmbedIT.testUrlOEmbedSoundCloud
    E2ESeleniumTestsGroup3.com.adobe.cq.wcm.core.components.it.seljup.tests.embed.v2.EmbedIT.testUrlValidation

See a proposed alternative in #2717

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants