Skip to content

Commit d35878e

Browse files
committed
wait for all three processes in sum (not on a single one)
1 parent 3ae8fae commit d35878e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/main/java/org/cryptomator/linux/revealpath/DBusFileMangerRevealPath.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import java.nio.file.Path;
1212
import java.nio.file.attribute.BasicFileAttributes;
1313
import java.util.Arrays;
14+
import java.util.concurrent.CountDownLatch;
1415
import java.util.concurrent.TimeUnit;
1516
import java.util.stream.Collectors;
1617

@@ -52,14 +53,18 @@ public void reveal(Path path) throws RevealFailedException {
5253

5354
@Override
5455
public boolean isSupported() {
56+
CountDownLatch waitBarrier = new CountDownLatch(3);
5557
ProcessBuilder builderExistsDbusSend = new ProcessBuilder().command("which", "dbus-send");
5658
ProcessBuilder builderExistsNautilus = new ProcessBuilder().command("which", "nautilus");
5759
ProcessBuilder builderExistsDolphin = new ProcessBuilder().command("which", "dolphin");
5860
try {
5961
var existsDbusSend = builderExistsDbusSend.start();
62+
existsDbusSend.onExit().thenRun(waitBarrier::countDown);
6063
var existsNautilus = builderExistsNautilus.start();
64+
existsNautilus.onExit().thenRun(waitBarrier::countDown);
6165
var existsDolphin = builderExistsDolphin.start();
62-
if (existsDbusSend.waitFor(TIMEOUT_THRESHOLD, TimeUnit.MILLISECONDS) && !existsDolphin.isAlive() && !existsNautilus.isAlive()) {
66+
existsDolphin.onExit().thenRun(waitBarrier::countDown);
67+
if (waitBarrier.await(TIMEOUT_THRESHOLD, TimeUnit.MILLISECONDS)) {
6368
return existsDbusSend.exitValue() == 0 && (existsNautilus.exitValue() == 0 | existsDolphin.exitValue() == 0);
6469
}
6570
} catch (IOException | InterruptedException e) {

0 commit comments

Comments
 (0)