11
11
import java .nio .file .Path ;
12
12
import java .nio .file .attribute .BasicFileAttributes ;
13
13
import java .util .Arrays ;
14
- import java .util .concurrent .CountDownLatch ;
15
14
import java .util .concurrent .TimeUnit ;
16
15
import java .util .stream .Collectors ;
17
16
@@ -60,20 +59,10 @@ public void reveal(Path path) throws RevealFailedException {
60
59
61
60
@ Override
62
61
public boolean isSupported () {
63
- CountDownLatch waitBarrier = new CountDownLatch (2 );
64
- ProcessBuilder dbusSendExistsBuilder = new ProcessBuilder ().command ("test" , " `command -v dbus-send`" );
65
- ProcessBuilder fileManager1ExistsBuilder = createFileManager1Check ();
66
-
67
62
try {
68
- var dbusSendExists = dbusSendExistsBuilder .start ();
69
- dbusSendExists .onExit ().thenRun (waitBarrier ::countDown );
70
- var fileManager1Exists = fileManager1ExistsBuilder .start ();
71
- fileManager1Exists .onExit ().thenRun (waitBarrier ::countDown );
72
-
73
- if (waitBarrier .await (TIMEOUT_THRESHOLD , TimeUnit .MILLISECONDS )) {
74
- if (dbusSendExists .exitValue () == 0 && fileManager1Exists .exitValue () == 0 ) {
75
- return parseOutputForFileManagerInterface (fileManager1Exists );
76
- }
63
+ var fileManager1Exists = createFileManager1Check ().start ();
64
+ if (fileManager1Exists .waitFor (TIMEOUT_THRESHOLD , TimeUnit .MILLISECONDS ) && fileManager1Exists .exitValue () == 0 ) {
65
+ return parseOutputForFileManagerInterface (fileManager1Exists );
77
66
}
78
67
} catch (IOException | InterruptedException e ) {
79
68
//NO-OP
@@ -90,7 +79,7 @@ public boolean isSupported() {
90
79
* @throws IOException if the Inputer reader on the process output cannot be created
91
80
*/
92
81
private boolean parseOutputForFileManagerInterface (Process fileManager1Process ) throws IOException {
93
- if ( fileManager1Process .isAlive ()) {
82
+ if ( fileManager1Process .isAlive ()) {
94
83
throw new IllegalArgumentException ("Process " + fileManager1Process + " must be terminated to read output." );
95
84
}
96
85
try (var reader = fileManager1Process .inputReader (StandardCharsets .UTF_8 )) {
0 commit comments