You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for contributing to Selenium! A PR well described will help maintainers to quickly review and merge it
Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.
Description
This pull request includes several refactorings to improve code readability and consistency across multiple files, primarily by replacing lambda expressions with method references and simplifying conditional checks.
Why: The suggestion addresses a potential runtime error by adding null checks for credential map values, which could prevent NullPointerException in production code.
8
General
Add logging for suppressed exceptions to improve error diagnostics and debugging
Consider handling the suppressed exception by logging it rather than just adding it to the suppressed exceptions list, as it contains important connection cleanup error details.
try {
client.ifPresent(HttpClient::close);
} catch (Exception ex) {
+ LOG.log(Level.WARNING, "Failed to close HTTP client", ex);
e.addSuppressed(ex);
}
Apply this suggestion
Suggestion importance[1-10]: 6
Why: Adding logging for suppressed exceptions would improve debugging capabilities by making cleanup errors more visible, while still maintaining the original exception handling behavior.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
Thanks for contributing to Selenium!
A PR well described will help maintainers to quickly review and merge it
Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.
Description
This pull request includes several refactorings to improve code readability and consistency across multiple files, primarily by replacing lambda expressions with method references and simplifying conditional checks.
Code readability improvements:
java/src/org/openqa/selenium/chromium/ChromiumDriver.java: Replaced lambda expression with method reference inprotected ChromiumDriverconstructor.java/src/org/openqa/selenium/devtools/SeleniumCdpConnection.java: Replaced lambda expressions with method references increatemethod and simplifiedifcondition to useisEmpty()instead of!isPresent(). [1] [2]java/src/org/openqa/selenium/firefox/FirefoxDriver.java: Replaced lambda expression with method reference inprivate FirefoxDriverconstructor.java/src/org/openqa/selenium/remote/RemoteWebDriver.java: Replaced lambda expression with method reference inaddCredentialmethod.Test code simplification:
java/test/org/openqa/selenium/NoSuchShadowRootTest.java: Simplified exception assertion by replacing lambda expression with method reference ingetNoSuchShadowRoottest method.java/test/org/openqa/selenium/grid/node/relay/RelayOptionsTest.java: Simplified exception assertion by replacing lambda expression with method reference inprotocolVersionThrowsConfigExceptiontest method.java/test/org/openqa/selenium/grid/server/BaseServerOptionsTest.java: Simplified exception assertion by replacing lambda expression with method reference inexternalUriFailsForNonUriStringstest method.Motivation and Context
While often it could be a matter of taste, method references are more clear and readable compared to lambdas.
Types of changes
Checklist
PR Type
enhancement, tests
Description
isEmpty()instead of!isPresent().Changes walkthrough 📝
ChromiumDriver.java
Use method reference in ChromiumDriver constructorjava/src/org/openqa/selenium/chromium/ChromiumDriver.java
ChromiumDriverconstructor.
SeleniumCdpConnection.java
Refactor SeleniumCdpConnection with method references and simplifiedconditionsjava/src/org/openqa/selenium/devtools/SeleniumCdpConnection.java
createmethod.isEmpty().FirefoxDriver.java
Use method reference in FirefoxDriver constructorjava/src/org/openqa/selenium/firefox/FirefoxDriver.java
FirefoxDriverconstructor.
RemoteWebDriver.java
Refactor addCredential method with method referencejava/src/org/openqa/selenium/remote/RemoteWebDriver.java
addCredentialmethod.
NoSuchShadowRootTest.java
Use method reference in NoSuchShadowRootTest assertionjava/test/org/openqa/selenium/NoSuchShadowRootTest.java
RelayOptionsTest.java
Use method reference in RelayOptionsTest assertionjava/test/org/openqa/selenium/grid/node/relay/RelayOptionsTest.java
BaseServerOptionsTest.java
Use method reference in BaseServerOptionsTest assertionjava/test/org/openqa/selenium/grid/server/BaseServerOptionsTest.java