1
1
/*
2
- * Copyright (c) 2015, 2020 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2015, 2021 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
@@ -88,6 +88,7 @@ public class LingeredApp {
88
88
private ByteArrayOutputStream stdoutBuffer ;
89
89
private Thread outPumperThread ;
90
90
private Thread errPumperThread ;
91
+ private boolean finishAppCalled = false ;
91
92
92
93
protected Process appProcess ;
93
94
protected OutputBuffer output ;
@@ -367,6 +368,11 @@ public void runAppExactJvmOpts(String[] vmOpts)
367
368
368
369
private void finishApp () {
369
370
if (appProcess != null ) {
371
+ if (finishAppCalled ) {
372
+ return ;
373
+ } else {
374
+ finishAppCalled = true ;
375
+ }
370
376
OutputBuffer output = getOutput ();
371
377
String msg =
372
378
" LingeredApp stdout: [" + output .getStdout () + "];\n " +
@@ -416,6 +422,8 @@ public static void startAppExactJvmOpts(LingeredApp theApp, String... jvmOpts) t
416
422
theApp .runAppExactJvmOpts (jvmOpts );
417
423
theApp .waitAppReady ();
418
424
} catch (Exception ex ) {
425
+ System .out .println ("LingeredApp failed to start: " + ex );
426
+ theApp .finishApp ();
419
427
theApp .deleteLock ();
420
428
throw ex ;
421
429
}
@@ -441,14 +449,7 @@ public static void startApp(LingeredApp theApp, String... additionalJvmOpts) thr
441
449
*/
442
450
public static LingeredApp startApp (String ... additionalJvmOpts ) throws IOException {
443
451
LingeredApp a = new LingeredApp ();
444
- try {
445
- startApp (a , additionalJvmOpts );
446
- } catch (Exception ex ) {
447
- System .out .println ("LingeredApp failed to start: " + ex );
448
- a .finishApp ();
449
- throw ex ;
450
- }
451
-
452
+ startApp (a , additionalJvmOpts );
452
453
return a ;
453
454
}
454
455
0 commit comments