diff --git a/CONTRIBUTORS b/CONTRIBUTORS index af1a509f4..74d6c636f 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -154,6 +154,7 @@ Ingenonsya France Ingmar Stein Irene Rusman Isaac Shabtay +Issa Gorissen Ivan Ivanov J Bleijenbergh Jack J. Woehr diff --git a/WHATSNEW b/WHATSNEW index a0c575dac..a2dd3d54b 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -80,6 +80,11 @@ Other changes: * now supports Java9 modules. https://github.com/apache/ant/pull/16 + * and have two new attributes serverAliveInterval and + serverAliveCountMax that can be used to keep a intermediaries from + closing idle connections. + Bugzilla Report 59162 + Changes from Ant 1.9.5 TO Ant 1.9.6 =================================== diff --git a/contributors.xml b/contributors.xml index 4029a0d09..85066b750 100644 --- a/contributors.xml +++ b/contributors.xml @@ -640,6 +640,10 @@ Isaac Shabtay + + Issa + Gorissen + Ivan Ivanov diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHBase.java b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHBase.java index 68419a85d..df7996a3f 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHBase.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHBase.java @@ -42,6 +42,8 @@ public abstract class SSHBase extends Task implements LogListener { private boolean failOnError = true; private boolean verbose; private final SSHUserInfo userInfo; + private int serverAliveCountMax = 3; + private int serverAliveIntervalSeconds = 0; /** * Constructor for SSHBase. @@ -104,6 +106,42 @@ public abstract class SSHBase extends Task implements LogListener { return verbose; } + /** + * Set the serverAliveCountMax value. + * @since Ant 1.9.7 + */ + public void setServerAliveCountMax(final int countMax) { + if (countMax <= 0) throw new IllegalArgumentException("ssh server alive count max setting cannot be negative or zero"); + this.serverAliveCountMax = countMax; + } + + /** + * Get the serverAliveCountMax value. + * @return the serverAliveCountMax value + * @since Ant 1.9.7 + */ + public int getServerAliveCountMax() { + return serverAliveCountMax; + } + + /** + * Set the serverAliveIntervalSeconds value in seconds. + * @since Ant 1.9.7 + */ + public void setServerAliveIntervalSeconds(final int interval) { + if (interval < 0) throw new IllegalArgumentException("ssh server alive interval setting cannot be negative"); + this.serverAliveIntervalSeconds = interval; + } + + /** + * Get the serverAliveIntervalSeconds value in seconds. + * @return the serverAliveIntervalSeconds value in seconds + * @since Ant 1.9.7 + */ + public int getServerAliveIntervalSeconds() { + return serverAliveIntervalSeconds; + } + /** * Username known to remote host. * @@ -221,6 +259,12 @@ public abstract class SSHBase extends Task implements LogListener { session.setConfig("PreferredAuthentications", "publickey,keyboard-interactive,password"); session.setUserInfo(userInfo); + + if (serverAliveIntervalSeconds > 0) { + session.setServerAliveCountMax(serverAliveCountMax); + session.setServerAliveInterval(serverAliveIntervalSeconds * 1000); + } + log("Connecting to " + host + ":" + port); session.connect(); return session;