Skip to content

Commit

Permalink
[java] use Files.notExists to check files #14088
Browse files Browse the repository at this point in the history
  • Loading branch information
joerg1985 committed Jun 22, 2024
1 parent da71ba3 commit 84828cd
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 84828cd

Please sign in to comment.