From 0592e84a3c07b4451e81d2eecc0c51af384858d2 Mon Sep 17 00:00:00 2001 From: ma-xiao-guang-64 Date: Wed, 9 May 2018 11:00:32 +0800 Subject: [PATCH] Fix isShutdown() always return true (#1426) --- .../alibaba/dubbo/common/utils/ExecutorUtil.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/ExecutorUtil.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/ExecutorUtil.java index 19d581f9947..6b07cc8035f 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/ExecutorUtil.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/ExecutorUtil.java @@ -34,9 +34,9 @@ public class ExecutorUtil { new LinkedBlockingQueue(100), new NamedThreadFactory("Close-ExecutorService-Timer", true)); - public static boolean isShutdown(Executor executor) { + public static boolean isTerminated(Executor executor) { if (executor instanceof ExecutorService) { - if (((ExecutorService) executor).isShutdown()) { + if (((ExecutorService) executor).isTerminated()) { return true; } } @@ -44,7 +44,7 @@ public static boolean isShutdown(Executor executor) { } public static void gracefulShutdown(Executor executor, int timeout) { - if (!(executor instanceof ExecutorService) || isShutdown(executor)) { + if (!(executor instanceof ExecutorService) || isTerminated(executor)) { return; } final ExecutorService es = (ExecutorService) executor; @@ -63,13 +63,13 @@ public static void gracefulShutdown(Executor executor, int timeout) { es.shutdownNow(); Thread.currentThread().interrupt(); } - if (!isShutdown(es)) { + if (!isTerminated(es)) { newThreadToCloseExecutor(es); } } public static void shutdownNow(Executor executor, final int timeout) { - if (!(executor instanceof ExecutorService) || isShutdown(executor)) { + if (!(executor instanceof ExecutorService) || isTerminated(executor)) { return; } final ExecutorService es = (ExecutorService) executor; @@ -85,13 +85,13 @@ public static void shutdownNow(Executor executor, final int timeout) { } catch (InterruptedException ex) { Thread.currentThread().interrupt(); } - if (!isShutdown(es)) { + if (!isTerminated(es)) { newThreadToCloseExecutor(es); } } private static void newThreadToCloseExecutor(final ExecutorService es) { - if (!isShutdown(es)) { + if (!isTerminated(es)) { shutdownExecutor.execute(new Runnable() { @Override public void run() {