Skip to content

Commit

Permalink
[java] use Files.notExists to check files SeleniumHQ#14088
Browse files Browse the repository at this point in the history
  • Loading branch information
joerg1985 authored and sandeepsuryaprasad committed Oct 29, 2024
1 parent 84ad63b commit 3d7b6b4
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions java/src/org/openqa/selenium/internal/Require.java
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,9 @@ public Path isFile() {
if (path == null) {
throw new IllegalStateException(String.format(MUST_BE_SET, name));
}
if (!Files.exists(path)) {
// notExists returns false in case it is impossible to determinate the exact result of a link
// target e.g. Windows app execution aliases
if (Files.notExists(path)) {
throw new IllegalStateException(String.format(MUST_EXIST, name, path));
}
if (!Files.isRegularFile(path)) {
Expand All @@ -455,7 +457,9 @@ public Path isDirectory() {
if (path == null) {
throw new IllegalStateException(String.format(MUST_BE_SET, name));
}
if (!Files.exists(path)) {
// notExists returns false in case it is impossible to determinate the exact result of a link
// target e.g. Windows app execution aliases
if (Files.notExists(path)) {
throw new IllegalStateException(String.format(MUST_EXIST, name, path));
}
if (!Files.isDirectory(path)) {
Expand All @@ -468,7 +472,9 @@ public Path isExecutable() {
if (path == null) {
throw new IllegalStateException(String.format(MUST_BE_SET, name));
}
if (!Files.exists(path)) {
// notExists returns false in case it is impossible to determinate the exact result of a link
// target e.g. Windows app execution aliases
if (Files.notExists(path)) {
throw new IllegalStateException(String.format(MUST_EXIST, name, path));
}
// do not check for isRegularFile here, there are executable none regular files e.g. Windows
Expand Down

0 comments on commit 3d7b6b4

Please sign in to comment.