[🐛 Bug]: When encounter an exception in RemoteWebDriverBuilder.build(), the underlaying HttpClient resources are not released
Description
var webDriver = RemoteWebDriver.builder().address(REMOTE_URL).build() In the above code when there is an exception in the build() method, no webDriver instance returned and I cannot release the underlaying HttpClient resources. Could we consider releasing the HttpClient resources inside the build() before throwing an exception? The exception example :
org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: java.io.IOException: Proxy-Authenticate header missing for response code 407 at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:114) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:75) at org.openqa.selenium.remote.RemoteWebDriverBuilder.getRemoteDriver(RemoteWebDriverBuilder.java:394) at org.openqa.selenium.remote.RemoteWebDriverBuilder.build(RemoteWebDriverBuilder.java:366)
Reproducible Code
var webDriver = RemoteWebDriver.builder().address(REMOTE_URL).build()
Debugging Logs
org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: java.io.IOException: Proxy-Authenticate header missing for response code 407
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:114)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:75)
at org.openqa.selenium.remote.RemoteWebDriverBuilder.getRemoteDriver(RemoteWebDriverBuilder.java:394)
at org.openqa.selenium.remote.RemoteWebDriverBuilder.build(RemoteWebDriverBuilder.java:366)
@jacklee1983, thank you for creating this issue. We will troubleshoot it as soon as we can.
Selenium Triage Team: remember to follow the Triage Guide
⚠️ You reported using Selenium version 4.24.0, but the latest release is 4.32.
Please verify that this issue still occurs with the latest version. If it no longer applies, you can close this issue or update your comment.
This issue will be marked "awaiting answer" and may be closed automatically if no response is received.
In the newest 4.32 version. the RemoteWebDriverBuilder.getRemoteDriver() method still doesn't release the HttpClient resources before throwing an exception.
Would you like to send a PR to improve this?
This issue is looking for contributors.
Please comment below or reach out to us through our IRC/Slack/Matrix channels if you are interested.
Let me look into the source code first.
@jacklee1983 should be fixed with c82f92ea2fbfe3e390158d53fcb318da097f0518 could you test it with a nightly build?
@joerg1985 Can you create Pull Requests for changes instead of pushing to trunk? It makes reverting and keeping track of changes much easier.
@cgoldberg yes, will do so in future. in the past i only did PRs for bigger things.
@joerg1985 thanks.. it's best to do so for all changes, even if it's a small change and you approve it yourself.
This issue was closed because we did not receive any additional information after 14 days.
This issue has been automatically locked since there has not been any recent activity since it was closed. Please open a new issue for related bugs.