From b8b2268d2e0bf185b1c4479b8c44688b7654f75a Mon Sep 17 00:00:00 2001 From: LamGC Date: Fri, 10 Sep 2021 01:25:57 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20CommandExecSession=20=E7=9A=84=20waitFo?= =?UTF-8?q?r(long)=20=E6=96=B9=E6=B3=95=E6=94=AF=E6=8C=81=E9=80=9A?= =?UTF-8?q?=E8=BF=87=E8=BF=94=E5=9B=9E=E5=80=BC=E4=BC=A0=E9=80=92=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E8=B6=85=E6=97=B6.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 现在 waitFor(long) 方法在超过指定时间返回后, 将会通过 boolean 返回值告诉调用方是否超时. 详细信息见 Javadoc. --- .../oracle/sentry/oci/compute/ssh/CommandExecSession.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/lamgc/oracle/sentry/oci/compute/ssh/CommandExecSession.java b/src/main/java/net/lamgc/oracle/sentry/oci/compute/ssh/CommandExecSession.java index 50f9a65..6bab533 100644 --- a/src/main/java/net/lamgc/oracle/sentry/oci/compute/ssh/CommandExecSession.java +++ b/src/main/java/net/lamgc/oracle/sentry/oci/compute/ssh/CommandExecSession.java @@ -54,9 +54,11 @@ public final class CommandExecSession implements Closeable { /** * 等待程序执行完毕. * @param timeout 超时时间, 0 为无限等待(单位: 毫秒). + * @return 如果在超时时间内返回, 返回 {@code true}, 超时返回 {@code false}. */ - public void waitFor(long timeout) { - channelExec.waitFor(EnumSet.of(ClientChannelEvent.EXIT_STATUS, ClientChannelEvent.EXIT_SIGNAL), timeout); + public boolean waitFor(long timeout) { + return !channelExec.waitFor(EnumSet.of(ClientChannelEvent.EXIT_STATUS, ClientChannelEvent.EXIT_SIGNAL), timeout) + .contains(ClientChannelEvent.TIMEOUT); } /**