Skip to content

Commit 84828cd

Browse files
committed
[java] use Files.notExists to check files #14088
1 parent da71ba3 commit 84828cd

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

java/src/org/openqa/selenium/internal/Require.java

+9-3
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,9 @@ public Path isFile() {
442442
if (path == null) {
443443
throw new IllegalStateException(String.format(MUST_BE_SET, name));
444444
}
445-
if (!Files.exists(path)) {
445+
// notExists returns false in case it is impossible to determinate the exact result of a link
446+
// target e.g. Windows app execution aliases
447+
if (Files.notExists(path)) {
446448
throw new IllegalStateException(String.format(MUST_EXIST, name, path));
447449
}
448450
if (!Files.isRegularFile(path)) {
@@ -455,7 +457,9 @@ public Path isDirectory() {
455457
if (path == null) {
456458
throw new IllegalStateException(String.format(MUST_BE_SET, name));
457459
}
458-
if (!Files.exists(path)) {
460+
// notExists returns false in case it is impossible to determinate the exact result of a link
461+
// target e.g. Windows app execution aliases
462+
if (Files.notExists(path)) {
459463
throw new IllegalStateException(String.format(MUST_EXIST, name, path));
460464
}
461465
if (!Files.isDirectory(path)) {
@@ -468,7 +472,9 @@ public Path isExecutable() {
468472
if (path == null) {
469473
throw new IllegalStateException(String.format(MUST_BE_SET, name));
470474
}
471-
if (!Files.exists(path)) {
475+
// notExists returns false in case it is impossible to determinate the exact result of a link
476+
// target e.g. Windows app execution aliases
477+
if (Files.notExists(path)) {
472478
throw new IllegalStateException(String.format(MUST_EXIST, name, path));
473479
}
474480
// do not check for isRegularFile here, there are executable none regular files e.g. Windows

0 commit comments

Comments
 (0)