From 0be5c462ae1082490e7563b35f4b5d0e6097dbf4 Mon Sep 17 00:00:00 2001 From: liubao Date: Tue, 10 Oct 2023 10:44:51 +0800 Subject: [PATCH] [#3960]fix vertx close may block shutdown --- .../apache/servicecomb/foundation/vertx/VertxUtils.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/foundations/foundation-vertx/src/main/java/org/apache/servicecomb/foundation/vertx/VertxUtils.java b/foundations/foundation-vertx/src/main/java/org/apache/servicecomb/foundation/vertx/VertxUtils.java index a3f7efa420..5cc68f13d8 100644 --- a/foundations/foundation-vertx/src/main/java/org/apache/servicecomb/foundation/vertx/VertxUtils.java +++ b/foundations/foundation-vertx/src/main/java/org/apache/servicecomb/foundation/vertx/VertxUtils.java @@ -25,7 +25,6 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import io.vertx.core.file.impl.FileResolverImpl; import org.apache.commons.io.IOUtils; import org.apache.servicecomb.foundation.common.Holder; import org.apache.servicecomb.foundation.common.concurrent.ConcurrentHashMapEx; @@ -44,6 +43,7 @@ import io.vertx.core.Vertx; import io.vertx.core.VertxOptions; import io.vertx.core.buffer.Buffer; +import io.vertx.core.file.impl.FileResolverImpl; import io.vertx.core.impl.VertxBuilder; import io.vertx.core.impl.VertxThread; import io.vertx.core.spi.VertxThreadFactory; @@ -192,7 +192,7 @@ public static CompletableFuture closeVertxByName(String name) { public static void blockCloseVertxByName(String name) { CompletableFuture future = closeVertxByName(name); try { - future.get(); + future.get(30, TimeUnit.SECONDS); } catch (Throwable e) { LOGGER.error("Failed to wait close vertx {}.", name, e); } @@ -211,8 +211,8 @@ public static void blockCloseVertx(Vertx vertx) { }); try { - latch.await(); - } catch (InterruptedException e) { + latch.await(30, TimeUnit.SECONDS); + } catch (Throwable e) { LOGGER.info("Failed to wait close vertx {}.", vertx); } }