Skip to content

Commit 0592e84

Browse files
maxiaoguang64ralf0131
authored andcommitted
Fix isShutdown() always return true (#1426)
1 parent 04c93e8 commit 0592e84

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/ExecutorUtil.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,17 @@ public class ExecutorUtil {
3434
new LinkedBlockingQueue<Runnable>(100),
3535
new NamedThreadFactory("Close-ExecutorService-Timer", true));
3636

37-
public static boolean isShutdown(Executor executor) {
37+
public static boolean isTerminated(Executor executor) {
3838
if (executor instanceof ExecutorService) {
39-
if (((ExecutorService) executor).isShutdown()) {
39+
if (((ExecutorService) executor).isTerminated()) {
4040
return true;
4141
}
4242
}
4343
return false;
4444
}
4545

4646
public static void gracefulShutdown(Executor executor, int timeout) {
47-
if (!(executor instanceof ExecutorService) || isShutdown(executor)) {
47+
if (!(executor instanceof ExecutorService) || isTerminated(executor)) {
4848
return;
4949
}
5050
final ExecutorService es = (ExecutorService) executor;
@@ -63,13 +63,13 @@ public static void gracefulShutdown(Executor executor, int timeout) {
6363
es.shutdownNow();
6464
Thread.currentThread().interrupt();
6565
}
66-
if (!isShutdown(es)) {
66+
if (!isTerminated(es)) {
6767
newThreadToCloseExecutor(es);
6868
}
6969
}
7070

7171
public static void shutdownNow(Executor executor, final int timeout) {
72-
if (!(executor instanceof ExecutorService) || isShutdown(executor)) {
72+
if (!(executor instanceof ExecutorService) || isTerminated(executor)) {
7373
return;
7474
}
7575
final ExecutorService es = (ExecutorService) executor;
@@ -85,13 +85,13 @@ public static void shutdownNow(Executor executor, final int timeout) {
8585
} catch (InterruptedException ex) {
8686
Thread.currentThread().interrupt();
8787
}
88-
if (!isShutdown(es)) {
88+
if (!isTerminated(es)) {
8989
newThreadToCloseExecutor(es);
9090
}
9191
}
9292

9393
private static void newThreadToCloseExecutor(final ExecutorService es) {
94-
if (!isShutdown(es)) {
94+
if (!isTerminated(es)) {
9595
shutdownExecutor.execute(new Runnable() {
9696
@Override
9797
public void run() {

0 commit comments

Comments
 (0)