+ public static void closeExecutorService(ExecutorService executor) {
+ executor.shutdown();
+ try {
+ if (!executor.awaitTermination(5, TimeUnit.MINUTES)) {
+ executor.shutdownNow();
+ if (!executor.awaitTermination(1, TimeUnit.MINUTES)) {
+ logger.warn("Failed to shutdown executor service");
+ }
+ }
+ } catch (InterruptedException e) {
+ executor.shutdownNow();
+ Thread.currentThread().interrupt();
+ }
+ }