This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mina-sshd.git
The following commit(s) were added to refs/heads/master by this push:
new 8744f06e7 [SSHD-1338] Restore binary compatibility with 2.9.2
8744f06e7 is described below
commit 8744f06e7c3ff24bc98535a91f6052ff7cf2f8d3
Author: Guillaume Nodet <[email protected]>
AuthorDate: Tue Jan 23 11:55:24 2024 +0100
[SSHD-1338] Restore binary compatibility with 2.9.2
---
.../apache/sshd/common/future/CancelOption.java | 2 +-
.../sshd/common/future/VerifiableFuture.java | 47 +++++++++++
.../apache/sshd/common/future/WaitableFuture.java | 91 ++++++++++++++++++++++
3 files changed, 139 insertions(+), 1 deletion(-)
diff --git
a/sshd-common/src/main/java/org/apache/sshd/common/future/CancelOption.java
b/sshd-common/src/main/java/org/apache/sshd/common/future/CancelOption.java
index 05162d6ed..749b0384d 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/future/CancelOption.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/future/CancelOption.java
@@ -40,7 +40,7 @@ public enum CancelOption {
/**
* Indicates that even if waiting on a future times out or is interrupted,
it shall not be canceled.
* <p>
- * {@link #CANCEL_ON_TIMEOUT} and {@link #CANCEL_ON_INTERRUPT} take
predence over this flag. The main purpose of
+ * {@link #CANCEL_ON_TIMEOUT} and {@link #CANCEL_ON_INTERRUPT} take
precedence over this flag. The main purpose of
* this flag is to be able to call {@code verify(timeout,
NO_CANCELLATION)} to suppress cancelling a future on
* time-outs or interrupts altogether. By default, {@code verify(timeout)}
will cancel the future on both time-outs
* and interrupts.
diff --git
a/sshd-common/src/main/java/org/apache/sshd/common/future/VerifiableFuture.java
b/sshd-common/src/main/java/org/apache/sshd/common/future/VerifiableFuture.java
index d3f93a47e..e44aeff3a 100644
---
a/sshd-common/src/main/java/org/apache/sshd/common/future/VerifiableFuture.java
+++
b/sshd-common/src/main/java/org/apache/sshd/common/future/VerifiableFuture.java
@@ -32,6 +32,17 @@ import java.util.concurrent.TimeUnit;
*/
@FunctionalInterface
public interface VerifiableFuture<T> {
+ /**
+ * Wait {@link Long#MAX_VALUE} msec. and verify that the operation was
successful
+ *
+ * @return The (same) future instance
+ * @throws IOException If failed to verify successfully on time
+ * @see #verify(long, CancelOption[])
+ */
+ default T verify() throws IOException {
+ return verify(Long.MAX_VALUE, new CancelOption[0]);
+ }
+
/**
* Wait {@link Long#MAX_VALUE} msec. and verify that the operation was
successful
*
@@ -45,6 +56,19 @@ public interface VerifiableFuture<T> {
return verify(Long.MAX_VALUE, options);
}
+ /**
+ * Wait and verify that the operation was successful
+ *
+ * @param timeout The number of time units to wait
+ * @param unit The wait {@link TimeUnit}
+ * @return The (same) future instance
+ * @throws IOException If failed to verify successfully on time
+ * @see #verify(long, CancelOption[])
+ */
+ default T verify(long timeout, TimeUnit unit) throws IOException {
+ return verify(timeout, unit, new CancelOption[0]);
+ }
+
/**
* Wait and verify that the operation was successful
*
@@ -60,6 +84,18 @@ public interface VerifiableFuture<T> {
return verify(unit.toMillis(timeout), options);
}
+ /**
+ * Wait and verify that the operation was successful
+ *
+ * @param timeout The maximum duration to wait, <code>null</code> to
wait forever
+ * @return The (same) future instance
+ * @throws IOException If failed to verify successfully on time
+ * @see #verify(long, CancelOption[])
+ */
+ default T verify(Duration timeout) throws IOException {
+ return verify(timeout, new CancelOption[0]);
+ }
+
/**
* Wait and verify that the operation was successful
*
@@ -74,6 +110,17 @@ public interface VerifiableFuture<T> {
return timeout != null ? verify(timeout.toMillis(), options) :
verify(options);
}
+ /**
+ * Wait and verify that the operation was successful
+ *
+ * @param timeoutMillis Wait timeout in milliseconds
+ * @return The (same) future instance
+ * @throws IOException If failed to verify successfully on time
+ */
+ default T verify(long timeoutMillis) throws IOException {
+ return verify(timeoutMillis, new CancelOption[0]);
+ }
+
/**
* Wait and verify that the operation was successful
*
diff --git
a/sshd-common/src/main/java/org/apache/sshd/common/future/WaitableFuture.java
b/sshd-common/src/main/java/org/apache/sshd/common/future/WaitableFuture.java
index 594c42b22..06398f463 100644
---
a/sshd-common/src/main/java/org/apache/sshd/common/future/WaitableFuture.java
+++
b/sshd-common/src/main/java/org/apache/sshd/common/future/WaitableFuture.java
@@ -36,6 +36,18 @@ public interface WaitableFuture {
*/
Object getId();
+ /**
+ * Wait {@link Long#MAX_VALUE} msec. for the asynchronous operation to
complete. The attached listeners will be
+ * notified when the operation is completed.
+ *
+ * @return {@code true} if the operation is completed.
+ * @throws IOException if failed - specifically {@link
java.io.InterruptedIOException} if waiting was interrupted
+ * @see #await(long, CancelOption[])
+ */
+ default boolean await() throws IOException {
+ return await(new CancelOption[0]);
+ }
+
/**
* Wait {@link Long#MAX_VALUE} msec. for the asynchronous operation to
complete. The attached listeners will be
* notified when the operation is completed.
@@ -50,6 +62,19 @@ public interface WaitableFuture {
return await(Long.MAX_VALUE, options);
}
+ /**
+ * Wait for the asynchronous operation to complete with the specified
timeout.
+ *
+ * @param timeout The number of time units to wait
+ * @param unit The {@link TimeUnit} for waiting
+ * @return {@code true} if the operation is completed.
+ * @throws IOException if failed - specifically {@link
java.io.InterruptedIOException} if waiting was interrupted
+ * @see #await(long, CancelOption[])
+ */
+ default boolean await(long timeout, TimeUnit unit) throws IOException {
+ return await(timeout, unit, new CancelOption[0]);
+ }
+
/**
* Wait for the asynchronous operation to complete with the specified
timeout.
*
@@ -65,6 +90,18 @@ public interface WaitableFuture {
return await(unit.toMillis(timeout), options);
}
+ /**
+ * Wait for the asynchronous operation to complete with the specified
timeout.
+ *
+ * @param timeout The maximum duration to wait, <code>null</code> to
wait forever
+ * @return {@code true} if the operation is completed.
+ * @throws IOException if failed - specifically {@link
java.io.InterruptedIOException} if waiting was interrupted
+ * @see #await(long, CancelOption[])
+ */
+ default boolean await(Duration timeout) throws IOException {
+ return await(timeout, new CancelOption[0]);
+ }
+
/**
* Wait for the asynchronous operation to complete with the specified
timeout.
*
@@ -79,6 +116,17 @@ public interface WaitableFuture {
return timeout != null ? await(timeout.toMillis(), options) :
await(options);
}
+ /**
+ * Wait for the asynchronous operation to complete with the specified
timeout.
+ *
+ * @param timeoutMillis Wait time in milliseconds
+ * @return {@code true} if the operation is completed.
+ * @throws IOException if failed - specifically {@link
java.io.InterruptedIOException} if waiting was interrupted
+ */
+ default boolean await(long timeoutMillis) throws IOException {
+ return await(timeoutMillis, new CancelOption[0]);
+ }
+
/**
* Wait for the asynchronous operation to complete with the specified
timeout.
*
@@ -90,6 +138,17 @@ public interface WaitableFuture {
*/
boolean await(long timeoutMillis, CancelOption... options) throws
IOException;
+ /**
+ * Wait {@link Long#MAX_VALUE} msec. for the asynchronous operation to
complete uninterruptibly. The attached
+ * listeners will be notified when the operation is completed.
+ *
+ * @return {@code true} if the operation is completed.
+ * @see #awaitUninterruptibly(long, CancelOption[])
+ */
+ default boolean awaitUninterruptibly() {
+ return awaitUninterruptibly(new CancelOption[0]);
+ }
+
/**
* Wait {@link Long#MAX_VALUE} msec. for the asynchronous operation to
complete uninterruptibly. The attached
* listeners will be notified when the operation is completed.
@@ -103,6 +162,18 @@ public interface WaitableFuture {
return awaitUninterruptibly(Long.MAX_VALUE, options);
}
+ /**
+ * Wait for the asynchronous operation to complete with the specified
timeout uninterruptibly.
+ *
+ * @param timeout The number of time units to wait
+ * @param unit The {@link TimeUnit} for waiting
+ * @return {@code true} if the operation is completed.
+ * @see #awaitUninterruptibly(long, CancelOption[])
+ */
+ default boolean awaitUninterruptibly(long timeout, TimeUnit unit) {
+ return awaitUninterruptibly(timeout, unit, new CancelOption[0]);
+ }
+
/**
* Wait for the asynchronous operation to complete with the specified
timeout uninterruptibly.
*
@@ -117,6 +188,16 @@ public interface WaitableFuture {
return awaitUninterruptibly(unit.toMillis(timeout), options);
}
+ /**
+ * Wait for the asynchronous operation to complete with the specified
timeout uninterruptibly.
+ *
+ * @param timeoutMillis Wait time, <code>null</code> to wait forever
+ * @return {@code true} if the operation is finished.
+ */
+ default boolean awaitUninterruptibly(Duration timeoutMillis) {
+ return awaitUninterruptibly(timeoutMillis, new CancelOption[0]);
+ }
+
/**
* Wait for the asynchronous operation to complete with the specified
timeout uninterruptibly.
*
@@ -129,6 +210,16 @@ public interface WaitableFuture {
return timeoutMillis != null ?
awaitUninterruptibly(timeoutMillis.toMillis(), options) :
awaitUninterruptibly(options);
}
+ /**
+ * Wait for the asynchronous operation to complete with the specified
timeout uninterruptibly.
+ *
+ * @param timeoutMillis Wait time in milliseconds
+ * @return {@code true} if the operation is finished.
+ */
+ default boolean awaitUninterruptibly(long timeoutMillis) {
+ return awaitUninterruptibly(timeoutMillis, new CancelOption[0]);
+ }
+
/**
* Wait for the asynchronous operation to complete with the specified
timeout uninterruptibly.
*