selenium
selenium copied to clipboard
14034: Eliminate assumption of mutable list argument in SeleniumManager.getBinaryPaths()
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
In the existing implementation, the getBinaryPaths(List<String> method assumes that the list supplied by the client is mutable, attempting to append its own items. If an immutable list is supplied, the method triggers UnsupportedOperationException.
Motivation and Context
Fixes #14034
Types of changes
- [X] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
Checklist
- [X] I have read the contributing document.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed.
PR Type
Bug fix
Description
- Fixed an issue in the
getBinaryPathsmethod where it assumed the input list was mutable, causing anUnsupportedOperationExceptionwhen an immutable list was provided. - Introduced a new
ArrayListto handle command line arguments, ensuring the original list remains unchanged. - Adjusted the method to add necessary arguments to the new list, including debug options if applicable.
Changes walkthrough 📝
| Relevant files | |||
|---|---|---|---|
| Bug fix |
|
💡 PR-Agent usage: Comment
/helpon the PR to get a list of all available PR-Agent tools and their descriptions
PR Review 🔍
| ⏱️ Estimated effort to review [1-5] |
2, because the changes are localized to a single method and involve straightforward modifications to handle list immutability correctly. The logic is simple and the amount of new code is minimal. |
| 🧪 Relevant tests |
No |
| ⚡ Possible issues |
Possible Bug: The PR does not mention if the new list creation with an increased capacity ( |
| 🔒 Security concerns |
No |
PR Code Suggestions ✨
| Category | Suggestion | Score |
| Possible bug |
Add a null check for the
| 8 |
| Maintainability |
Extract the addition of constant arguments into a separate method for better readability and maintainabilityTo improve readability and maintainability, consider extracting the addition of constant java/src/org/openqa/selenium/manager/SeleniumManager.java [238-241]
Suggestion importance[1-10]: 7Why: Extracting repetitive code into a method improves maintainability and readability. This is a good practice, especially in a method that might be modified or extended in the future. | 7 |
| Best practice |
Use the default constructor of
| 6 |
| Possible issue |
Make the
| 5 |