Skip to content

Commit db3392f

Browse files
committed
Fix a case-sensitive issue with ProcessUtil.pathOfCommand(Path path) on Windows
1 parent 018956a commit db3392f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

process/src/main/java/io/smallrye/common/process/ProcessUtil.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.smallrye.common.process;
22

33
import java.io.File;
4+
import java.io.IOException;
45
import java.nio.charset.Charset;
56
import java.nio.charset.UnsupportedCharsetException;
67
import java.nio.file.Files;
@@ -96,6 +97,14 @@ public static Optional<Path> pathOfCommand(Path path) {
9697
for (String ext : Windows.pathExt) {
9798
Path execPathExt = execPath.getParent().resolve(execPath.getFileName() + ext);
9899
if (Files.isExecutable(execPathExt)) {
100+
// This will ensure we get the case-sensitive real path.
101+
// e.g., C:\Program Files\Docker\Docker\resources\bin\docker.EXE becomes
102+
// C:\Program Files\Docker\Docker\resources\bin\docker.exe
103+
try {
104+
execPathExt = execPathExt.toRealPath();
105+
} catch (IOException e) {
106+
throw new RuntimeException(e);
107+
}
99108
return Optional.of(execPathExt);
100109
}
101110
}

0 commit comments

Comments
 (0)