Closed vlad8x8 closed 1 week ago
⏱️ Estimated effort to review [1-5] | 2 |
🧪 Relevant tests | No |
🔒 Security concerns | No |
⚡ Key issues to review |
Possible Bug: The method isWindowsAppExecutionAlias checks for the DOS file attribute but does not handle exceptions other than IOException . Consider handling or documenting other potential exceptions that might be thrown by Files.getAttribute . |
Code Clarity: The method isWindowsAppExecutionAlias could benefit from more detailed comments explaining the significance of the WINDOWS_FILE_ATTRIBUTE_REPARSE_POINT and how it relates to Windows app execution aliases. |
Category | Suggestion | Score |
Performance |
Cache the result of checking if DOS attributes are supported to improve performance___ **TheisWindowsAppExecutionAlias method should cache the result of FileSystems.getDefault().supportedFileAttributeViews().contains("dos") to avoid repeatedly calling this method, which can be expensive.** [java/src/org/openqa/selenium/internal/Require.java [372-373]](https://github.com/SeleniumHQ/selenium/pull/14151/files#diff-f50b7e191924359188430521dce38b2907db5e70cb9939e89a8f8d8c74cf22fcR372-R373) ```diff -if (!FileSystems.getDefault().supportedFileAttributeViews().contains("dos")) { +boolean supportsDosAttributes = FileSystems.getDefault().supportedFileAttributeViews().contains("dos"); +if (!supportsDosAttributes) { return false; } ``` - [ ] **Apply this suggestion** Suggestion importance[1-10]: 7Why: Caching the result of the DOS attribute check is a valid performance improvement, especially if this method is called frequently. | 7 |
Use a local variable for
___
**In the | 7 | |
Best practice |
Log the
___
**In the | 6 |
This PR does mix the java.io
and the java.nio
way of doing things. I would suggest to deprecate the java.io
stuff (using the File class) and create a new isExecutable
using the Path, which does not call isRegularFile
. @vlad8x8 would you like to update the PR or should i do the change?
Hi @joerg1985 . Unfortunatelly Files.isExecutable(path)
and file.isExecutable()
returns different values for Windows app execution aliases. Feel free to change it as you want, if it works for Windows app execution aliases.
You can find some aliases on Win10 in folder <UserFolder>\AppData\Local\Microsoft\WindowsApps
Targets for those aliases you can find in Windows registry HKCU:/SOFTWARE/Microsoft/Windows/CurrentVersion/App Paths
@vlad8x8 i have pushed a fix in 2a7ddf1fdeb724bb5f4bd6cd64867894aa485add therefore i close this. Thanks for reporting and helping to locate the issue.
@joerg1985 did you test your commit against app execution aliases? java.nio.file.LinkOption.NOFOLLOW_LINKS is critical for them, but you don't use it in your PR
I have tested Files.isExecutable
does return true for msteams.exe
, but i will double check it tomorrow with the nightly build.
User description
Fix for https://github.com/SeleniumHQ/selenium/issues/14088
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.
Fix for #14088
Description
Check if the browser path is Windows app execution alias before checking if it's a file.
Motivation and Context
Selenium manager is failing on Windows app execution aliases
Types of changes
Checklist
PR Type
Bug fix
Description
isWindowsAppExecutionAlias
to check if the browser path is a Windows app execution alias.isExecutable
method to use the new alias check before verifying if the file is executable.Changes walkthrough 📝
Require.java
Add Windows app execution alias check in Require.java
java/src/org/openqa/selenium/internal/Require.java
isWindowsAppExecutionAlias
to check for Windows appexecution aliases.
isExecutable
method to incorporate the new alias check beforeverifying if the file is executable.