4
4
import java .util .concurrent .CompletableFuture ;
5
5
6
6
import org .eclipse .core .runtime .CoreException ;
7
- import org .eclipse .core .runtime .Status ;
7
+ import org .eclipse .core .runtime .IStatus ;
8
8
import org .eclipse .core .runtime .jobs .Job ;
9
9
import org .eclipse .debug .core .DebugPlugin ;
10
10
import org .eclipse .debug .core .ILaunch ;
11
11
12
12
public class LaunchHelper {
13
13
14
-
15
14
public static Job createJob (ILaunch launch , String command , String workingDirectory ) {
16
15
return createJob (launch , command , new File (workingDirectory ));
17
16
}
@@ -27,32 +26,28 @@ public static Job createJob(ILaunch launch, String command, File workingDirector
27
26
}
28
27
CompletableFuture <Process > future = process .onExit ();
29
28
// initialize a process completion future to log any non-zero process exit
30
- future .defaultExecutor ().execute (new Runnable () {
31
- @ Override
32
- public void run () {
33
- try {
34
- if (process .isAlive ()) {
35
- process .waitFor ();
36
- }
37
- } catch (InterruptedException e ) {
38
- LogHelper .cancelled ("Process monitor interrupted: " + command );
39
- return ;
40
- }
41
- int exc = process .exitValue ();
42
- if (exc != 0 ) {
43
- String msg = String .format ("Process exited non-zero (%d): %s " , exc , command );
44
- LogHelper .error (msg );
29
+ future .defaultExecutor ().execute (() -> {
30
+ try {
31
+ if (process .isAlive ()) {
32
+ process .waitFor ();
45
33
}
34
+ } catch (InterruptedException e ) {
35
+ LogHelper .cancelled ("Process monitor interrupted: " + command );
36
+ return ;
37
+ }
38
+ int exc = process .exitValue ();
39
+ if (exc != 0 ) {
40
+ String msg = String .format ("Process exited non-zero (%d): %s " , exc , command );
41
+ LogHelper .error (msg );
46
42
}
47
-
48
43
});
49
44
DebugPlugin .newProcess (launch , process , command );
50
45
} catch (CoreException e ) {
51
46
// CoreException from exec
52
- LogHelper .log (Status .ERROR , "Exception when launching process: " + command , e );
47
+ LogHelper .log (IStatus .ERROR , "Exception when launching process: " + command , e );
53
48
return ;
54
49
}
55
50
});
56
51
}
57
52
58
- };;
53
+ }
0 commit comments