Repository navigation
[java] Do not leak the HttpClient on startup failure - #18047
Conversation
29f6d51 to
7b117e1
Compare
7b117e1 to
100ac7a
Compare
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
Code Review by Qodo
1.
|
Tracing is enabled by default, so RemoteWebDriver usually wraps the HttpCommandExecutor in a TracedCommandExecutor, which the previous HttpCommandExecutor type check skipped. TracedCommandExecutor now forwards close() to its delegate, and RemoteWebDriver closes any Closeable executor when session start fails or on quit(), without letting a close failure mask the original outcome. Also replaces the try-with-resources clean-up idioms with plain try/finally and adds unit tests for plain, traced and quit paths. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Code review by qodo was updated up to the latest commit 5cd71aa |
If startSession() fails after the session id is set (e.g. while setting up BiDi), the constructor calls quit() to end the remote session. Closing the executor in startSession() first made that QUIT fail, leaving the remote session open. Only close it there when there is no session id; otherwise quit() sends QUIT and then closes the executor. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Code review by qodo was updated up to the latest commit e610932 |
🔗 Related Issues
When
new RemoteWebDriver(...)fails to start a session, theHttpClientinside the command executor is never closed. It leaks until garbage collection.💥 What does this PR do?
HttpCommandExecutorimplementsCloseable.close()closes itsHttpClient.TracedCommandExecutorimplementsCloseable.close()closes the executor it wraps. Tracing is on by default, so this is the executor most users get.DriverCommandExecutor.close()also closes itsHttpClientnow.RemoteWebDrivercloses the executor if it implementsCloseable:quit(), even if the QUIT command fails🔧 Implementation Notes
HttpClientis aCloseable, andCloseable.close()must have no effect when called again.💡 Additional Considerations
Behavior change: if you pass your own executor to
new RemoteWebDriver(executor, caps), it is now closed when the session fails to start. You can't reuse that executor to retry. Create a new one instead. Retrying withnew RemoteWebDriver(url, caps)is not affected, because it creates a new executor each time.If users need to reuse their executor, we can add a way for
RemoteWebDriverto only close executors it created itself.🤖 AI assistance
TracedCommandExecutor, theRemoteWebDriverandDriverCommandExecutorclean-up changes, and the new unit tests🔄 Types of changes
🤖 Generated with Claude Code