[java] Improve error message for died grid#16938
Conversation
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
|||||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||
This test left 3 browsers open :( The reason is that 1. it stopped grid first, 2. and hoped that JupiterTestBase will close `localDriver`. 3. But when JupiterTestBase tried to close `localDriver`, it failed because its `remoteUrl` was not available anymore (the grid had been already stopped).
When throwing UnreachableBrowserException, it's important to mention URL of Selenium Grid (which is actually unavailable). Then user knows what's the real reason of "unreachable browser".
ed037a5 to
e880354
Compare
java/src/org/openqa/selenium/remote/http/jdk/JdkHttpClient.java
Outdated
Show resolved
Hide resolved
java/src/org/openqa/selenium/remote/http/jdk/ProtocolException.java
Outdated
Show resolved
Hide resolved
6b67672 to
3dee8fc
Compare
java/src/org/openqa/selenium/remote/http/jdk/JdkHttpClient.java
Outdated
Show resolved
Hide resolved
d61e953 to
2eaa657
Compare
User description
💥 What does this PR do?
RemoteWebDriverBiDiTest- closes 3 browsers that left open after this testUnreachableBrowserException.🔄 Types of changes
PR Type
Bug fix, Enhancement
Description
Improves error messages in BiDi and HTTP client exceptions with contextual details
Adds new
ConnectionExceptionandProtocolExceptionclasses for better error reportingFixes
RemoteWebDriverBiDiTestresource leak by explicitly closing browser before grid shutdownEnhances logging with formatted messages including HTTP method, URI, and WebSocket close codes
Old stack trace
It creates a misleading impression: feels like browser is died, while in reality Selenium Grid is stopped.
New stack trace
Still not perfect, but at least it gives a hint that this specific URL is not connectable.
Diagram Walkthrough
File Walkthrough
3 files
Throw exception for invalid BiDi URLAdd logging and null handler checkHandle ConnectionException with URI details6 files
Improve BiDi logging with detailed contextImprove close message error loggingAdd toString method for debuggingNew exception class for connection errorsEnhance HTTP error messages with method and URINew exception class for protocol errors1 files
Fix resource leak by closing driver explicitly1 files
Add logging configuration for tests