File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
java/test/org/openqa/selenium/testing Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change 22
22
import java .util .concurrent .CompletableFuture ;
23
23
import java .util .concurrent .ExecutorService ;
24
24
import java .util .concurrent .Executors ;
25
+ import java .util .concurrent .TimeUnit ;
26
+ import java .util .concurrent .TimeoutException ;
27
+ import java .util .logging .Level ;
28
+ import java .util .logging .Logger ;
25
29
26
30
public class Safely {
27
31
32
+ private static final Logger LOG = Logger .getLogger (Safely .class .getName ());
33
+
28
34
public static void safelyCall (TearDownFixture ... fixtures ) {
29
35
ExecutorService executor = Executors .newFixedThreadPool (fixtures .length );
30
36
List <CompletableFuture <Void >> futures = new LinkedList <>();
@@ -44,10 +50,14 @@ public static void safelyCall(TearDownFixture... fixtures) {
44
50
futures .add (check );
45
51
}
46
52
53
+ executor .shutdown ();
54
+
47
55
try {
48
- CompletableFuture .allOf (futures .toArray (new CompletableFuture [] {}));
49
- } finally {
50
- executor .shutdownNow ();
56
+ CompletableFuture .allOf (futures .toArray (new CompletableFuture [] {})).get (2 , TimeUnit .MINUTES );
57
+ } catch (TimeoutException ex ) {
58
+ LOG .log (Level .WARNING , "tear down timed out" );
59
+ } catch (Exception ex ) {
60
+ LOG .log (Level .WARNING , "tear down failed" , ex );
51
61
}
52
62
}
53
63
}
You can’t perform that action at this time.
0 commit comments