Skip to content

Commit 520e27a

Browse files
committed
Prep for 7.1
1 parent 26f1b7a commit 520e27a

File tree

1 file changed

+21
-23
lines changed

1 file changed

+21
-23
lines changed

hibernate-testing/src/main/java/org/hibernate/testing/orm/AsyncExecutor.java

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,31 @@
1414
*/
1515
public class AsyncExecutor {
1616
public static void executeAsync(Runnable action) {
17-
try (ExecutorService executorService = Executors.newSingleThreadExecutor()) {
18-
try {
19-
executorService.submit( action ).get();
20-
}
21-
catch (InterruptedException e) {
22-
throw new RuntimeException( "Thread interruption", e );
23-
}
24-
catch (ExecutionException e) {
25-
throw new RuntimeException( "Async execution error", e );
26-
}
17+
final ExecutorService executorService = Executors.newSingleThreadExecutor();
18+
try {
19+
executorService.submit( action ).get();
20+
}
21+
catch (InterruptedException e) {
22+
throw new RuntimeException( "Thread interruption", e );
23+
}
24+
catch (ExecutionException e) {
25+
throw new RuntimeException( "Async execution error", e );
2726
}
2827
}
2928

3029
public static void executeAsync(int timeout, TimeUnit timeoutUnit, Runnable action) {
31-
try (ExecutorService executorService = Executors.newSingleThreadExecutor()) {
32-
try {
33-
executorService.submit( action ).get( timeout, timeoutUnit );
34-
}
35-
catch (InterruptedException e) {
36-
throw new TimeoutException( "Thread interruption", e );
37-
}
38-
catch (java.util.concurrent.TimeoutException e) {
39-
throw new TimeoutException( "Thread timeout exceeded", e );
40-
}
41-
catch (ExecutionException e) {
42-
throw new RuntimeException( "Async execution error", e.getCause() );
43-
}
30+
final ExecutorService executorService = Executors.newSingleThreadExecutor();
31+
try {
32+
executorService.submit( action ).get( timeout, timeoutUnit );
33+
}
34+
catch (InterruptedException e) {
35+
throw new TimeoutException( "Thread interruption", e );
36+
}
37+
catch (java.util.concurrent.TimeoutException e) {
38+
throw new TimeoutException( "Thread timeout exceeded", e );
39+
}
40+
catch (ExecutionException e) {
41+
throw new RuntimeException( "Async execution error", e.getCause() );
4442
}
4543
}
4644

0 commit comments

Comments
 (0)