From 6d19be804ed64075bdcc52856023212ef48d1911 Mon Sep 17 00:00:00 2001 From: zhangzhiyong Date: Mon, 11 Nov 2024 19:53:19 +0800 Subject: [PATCH] =?UTF-8?q?=20feat:=20uds=20=E8=B6=85=E6=97=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/xiaomi/data/push/uds/UdsClient.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/jcommon/rcurve/src/main/java/com/xiaomi/data/push/uds/UdsClient.java b/jcommon/rcurve/src/main/java/com/xiaomi/data/push/uds/UdsClient.java index 55ec1dbf6..50177d278 100644 --- a/jcommon/rcurve/src/main/java/com/xiaomi/data/push/uds/UdsClient.java +++ b/jcommon/rcurve/src/main/java/com/xiaomi/data/push/uds/UdsClient.java @@ -33,6 +33,7 @@ import io.netty.channel.unix.DomainSocketAddress; import io.netty.handler.codec.LengthFieldBasedFrameDecoder; import io.netty.handler.codec.LengthFieldPrepender; +import io.netty.util.Timeout; import lombok.Getter; import lombok.Setter; import lombok.extern.slf4j.Slf4j; @@ -166,7 +167,7 @@ public UdsCommand call(UdsCommand req) { log.debug("start send,id:{}", id); Send.send(channel, req); - wheelTimer.newTimeout(() -> { + Timeout timeout = wheelTimer.newTimeout(() -> { log.warn("check async udsClient time out auto close:{},{}", req.getId(), req.getTimeout()); HashMap map = reqMap.remove(req.getId()); if (null != map) { @@ -177,7 +178,10 @@ public UdsCommand call(UdsCommand req) { ); } } - }, req.getTimeout() + 350); + }, req.getTimeout() + 200); + + // 添加完成时取消定时任务的回调 + future.whenComplete((k, v) -> timeout.cancel()); //异步还是同步 if (req.isAsync()) {