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

[java] Revert workaround for old netty http client (addendum to #12843) #14134

Merged
merged 5 commits into from
Jul 11, 2024

Conversation

kool79
Copy link
Contributor

@kool79 kool79 commented Jun 13, 2024

User description

Workaround was made as part of the fix (3f7f57c) the bug #11750 which was specific for netty client only. Since #12843 the netty client was removed.


PR Type

enhancement


Description

  • Removed deprecated workaround code for --remote-allow-origins argument in ChromiumOptions.java.
  • Corrected a typo in the Javadoc comment for the addArguments method.

Changes walkthrough 📝

Relevant files
Cleanup
ChromiumOptions.java
Remove deprecated workaround and fix Javadoc typo               

java/src/org/openqa/selenium/chromium/ChromiumOptions.java

  • Removed workaround code related to --remote-allow-origins argument.
  • Corrected typo in Javadoc comment.
  • +1/-13   

    💡 PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    …iumHQ#12843)
    
    Workaround was made as part of the fix (3f7f57c) the bug SeleniumHQ#11750 which was specific for netty client only.
    Since SeleniumHQ#12843 the netty client was removed.
    Copy link
    Contributor

    PR Reviewer Guide 🔍

    ⏱️ Estimated effort to review [1-5]

    2

    🧪 Relevant tests

    No

    🔒 Security concerns

    No

    ⚡ Key issues to review

    Possible Bug:
    The removal of the workaround for "--remote-allow-origins" assumes that all users will be on Chrome 111 or later. This might not be the case, and could lead to unexpected behavior if older versions of Chrome are used.

    Copy link
    Contributor

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Possible issue
    Add a null check for the arguments parameter to prevent potential NullPointerException

    Consider adding a null check for the arguments parameter to prevent potential
    NullPointerException when addArguments is called with a null value.

    java/src/org/openqa/selenium/chromium/ChromiumOptions.java [128-131]

     public T addArguments(List<String> arguments) {
    +  if (arguments == null) {
    +    throw new IllegalArgumentException("Arguments list cannot be null");
    +  }
       args.addAll(arguments);
       return (T) this;
     }
     
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    Why: Adding a null check is crucial to prevent runtime exceptions and ensure robustness of the method.

    8
    Add a check to ensure that the arguments list does not contain any null elements

    Consider adding a check to ensure that the arguments list does not contain any null
    elements to prevent potential issues when processing the arguments.

    java/src/org/openqa/selenium/chromium/ChromiumOptions.java [128-131]

     public T addArguments(List<String> arguments) {
    +  Objects.requireNonNull(arguments, "Arguments list cannot be null");
    +  if (arguments.contains(null)) {
    +    throw new IllegalArgumentException("Arguments list cannot contain null elements");
    +  }
       args.addAll(arguments);
       return (T) this;
     }
     
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    Why: Ensuring no null elements in the list can prevent runtime issues during the processing of arguments, enhancing method reliability.

    7
    Best practice
    Use Objects.requireNonNull for the null check on the arguments parameter to improve readability

    To improve readability and maintainability, consider using Objects.requireNonNull for the
    null check on the arguments parameter.

    java/src/org/openqa/selenium/chromium/ChromiumOptions.java [128-131]

     public T addArguments(List<String> arguments) {
    -  if (arguments == null) {
    -    throw new IllegalArgumentException("Arguments list cannot be null");
    -  }
    +  Objects.requireNonNull(arguments, "Arguments list cannot be null");
       args.addAll(arguments);
       return (T) this;
     }
     
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    Why: Using Objects.requireNonNull enhances code readability and maintainability, aligning with Java best practices.

    7
    Performance
    Automatically filter out any null elements from the arguments list to enhance performance

    To enhance performance, consider using
    args.addAll(arguments.stream().filter(Objects::nonNull).collect(Collectors.toList())) to
    automatically filter out any null elements from the arguments list.

    java/src/org/openqa/selenium/chromium/ChromiumOptions.java [128-131]

     public T addArguments(List<String> arguments) {
    -  args.addAll(arguments);
    +  Objects.requireNonNull(arguments, "Arguments list cannot be null");
    +  args.addAll(arguments.stream().filter(Objects::nonNull).collect(Collectors.toList()));
       return (T) this;
     }
     
    • Apply this suggestion
    Suggestion importance[1-10]: 6

    Why: While filtering nulls enhances data integrity, the performance gain might be minimal unless the list is large or operations on it are frequent.

    6

    Copy link
    Member

    @diemol diemol left a comment

    Choose a reason for hiding this comment

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

    This makes sense, thank you!

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

    Successfully merging this pull request may close these issues.

    3 participants