Skip to content

Commit 8744f06

Browse files
committed
[SSHD-1338] Restore binary compatibility with 2.9.2
1 parent 44a0b1b commit 8744f06

File tree

3 files changed

+139
-1
lines changed

3 files changed

+139
-1
lines changed

sshd-common/src/main/java/org/apache/sshd/common/future/CancelOption.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public enum CancelOption {
4040
/**
4141
* Indicates that even if waiting on a future times out or is interrupted, it shall not be canceled.
4242
* <p>
43-
* {@link #CANCEL_ON_TIMEOUT} and {@link #CANCEL_ON_INTERRUPT} take predence over this flag. The main purpose of
43+
* {@link #CANCEL_ON_TIMEOUT} and {@link #CANCEL_ON_INTERRUPT} take precedence over this flag. The main purpose of
4444
* this flag is to be able to call {@code verify(timeout, NO_CANCELLATION)} to suppress cancelling a future on
4545
* time-outs or interrupts altogether. By default, {@code verify(timeout)} will cancel the future on both time-outs
4646
* and interrupts.

sshd-common/src/main/java/org/apache/sshd/common/future/VerifiableFuture.java

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@
3232
*/
3333
@FunctionalInterface
3434
public interface VerifiableFuture<T> {
35+
/**
36+
* Wait {@link Long#MAX_VALUE} msec. and verify that the operation was successful
37+
*
38+
* @return The (same) future instance
39+
* @throws IOException If failed to verify successfully on time
40+
* @see #verify(long, CancelOption[])
41+
*/
42+
default T verify() throws IOException {
43+
return verify(Long.MAX_VALUE, new CancelOption[0]);
44+
}
45+
3546
/**
3647
* Wait {@link Long#MAX_VALUE} msec. and verify that the operation was successful
3748
*
@@ -45,6 +56,19 @@ default T verify(CancelOption... options) throws IOException {
4556
return verify(Long.MAX_VALUE, options);
4657
}
4758

59+
/**
60+
* Wait and verify that the operation was successful
61+
*
62+
* @param timeout The number of time units to wait
63+
* @param unit The wait {@link TimeUnit}
64+
* @return The (same) future instance
65+
* @throws IOException If failed to verify successfully on time
66+
* @see #verify(long, CancelOption[])
67+
*/
68+
default T verify(long timeout, TimeUnit unit) throws IOException {
69+
return verify(timeout, unit, new CancelOption[0]);
70+
}
71+
4872
/**
4973
* Wait and verify that the operation was successful
5074
*
@@ -60,6 +84,18 @@ default T verify(long timeout, TimeUnit unit, CancelOption... options) throws IO
6084
return verify(unit.toMillis(timeout), options);
6185
}
6286

87+
/**
88+
* Wait and verify that the operation was successful
89+
*
90+
* @param timeout The maximum duration to wait, <code>null</code> to wait forever
91+
* @return The (same) future instance
92+
* @throws IOException If failed to verify successfully on time
93+
* @see #verify(long, CancelOption[])
94+
*/
95+
default T verify(Duration timeout) throws IOException {
96+
return verify(timeout, new CancelOption[0]);
97+
}
98+
6399
/**
64100
* Wait and verify that the operation was successful
65101
*
@@ -74,6 +110,17 @@ default T verify(Duration timeout, CancelOption... options) throws IOException {
74110
return timeout != null ? verify(timeout.toMillis(), options) : verify(options);
75111
}
76112

113+
/**
114+
* Wait and verify that the operation was successful
115+
*
116+
* @param timeoutMillis Wait timeout in milliseconds
117+
* @return The (same) future instance
118+
* @throws IOException If failed to verify successfully on time
119+
*/
120+
default T verify(long timeoutMillis) throws IOException {
121+
return verify(timeoutMillis, new CancelOption[0]);
122+
}
123+
77124
/**
78125
* Wait and verify that the operation was successful
79126
*

sshd-common/src/main/java/org/apache/sshd/common/future/WaitableFuture.java

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,18 @@ public interface WaitableFuture {
3636
*/
3737
Object getId();
3838

39+
/**
40+
* Wait {@link Long#MAX_VALUE} msec. for the asynchronous operation to complete. The attached listeners will be
41+
* notified when the operation is completed.
42+
*
43+
* @return {@code true} if the operation is completed.
44+
* @throws IOException if failed - specifically {@link java.io.InterruptedIOException} if waiting was interrupted
45+
* @see #await(long, CancelOption[])
46+
*/
47+
default boolean await() throws IOException {
48+
return await(new CancelOption[0]);
49+
}
50+
3951
/**
4052
* Wait {@link Long#MAX_VALUE} msec. for the asynchronous operation to complete. The attached listeners will be
4153
* notified when the operation is completed.
@@ -50,6 +62,19 @@ default boolean await(CancelOption... options) throws IOException {
5062
return await(Long.MAX_VALUE, options);
5163
}
5264

65+
/**
66+
* Wait for the asynchronous operation to complete with the specified timeout.
67+
*
68+
* @param timeout The number of time units to wait
69+
* @param unit The {@link TimeUnit} for waiting
70+
* @return {@code true} if the operation is completed.
71+
* @throws IOException if failed - specifically {@link java.io.InterruptedIOException} if waiting was interrupted
72+
* @see #await(long, CancelOption[])
73+
*/
74+
default boolean await(long timeout, TimeUnit unit) throws IOException {
75+
return await(timeout, unit, new CancelOption[0]);
76+
}
77+
5378
/**
5479
* Wait for the asynchronous operation to complete with the specified timeout.
5580
*
@@ -65,6 +90,18 @@ default boolean await(long timeout, TimeUnit unit, CancelOption... options) thro
6590
return await(unit.toMillis(timeout), options);
6691
}
6792

93+
/**
94+
* Wait for the asynchronous operation to complete with the specified timeout.
95+
*
96+
* @param timeout The maximum duration to wait, <code>null</code> to wait forever
97+
* @return {@code true} if the operation is completed.
98+
* @throws IOException if failed - specifically {@link java.io.InterruptedIOException} if waiting was interrupted
99+
* @see #await(long, CancelOption[])
100+
*/
101+
default boolean await(Duration timeout) throws IOException {
102+
return await(timeout, new CancelOption[0]);
103+
}
104+
68105
/**
69106
* Wait for the asynchronous operation to complete with the specified timeout.
70107
*
@@ -79,6 +116,17 @@ default boolean await(Duration timeout, CancelOption... options) throws IOExcept
79116
return timeout != null ? await(timeout.toMillis(), options) : await(options);
80117
}
81118

119+
/**
120+
* Wait for the asynchronous operation to complete with the specified timeout.
121+
*
122+
* @param timeoutMillis Wait time in milliseconds
123+
* @return {@code true} if the operation is completed.
124+
* @throws IOException if failed - specifically {@link java.io.InterruptedIOException} if waiting was interrupted
125+
*/
126+
default boolean await(long timeoutMillis) throws IOException {
127+
return await(timeoutMillis, new CancelOption[0]);
128+
}
129+
82130
/**
83131
* Wait for the asynchronous operation to complete with the specified timeout.
84132
*
@@ -90,6 +138,17 @@ default boolean await(Duration timeout, CancelOption... options) throws IOExcept
90138
*/
91139
boolean await(long timeoutMillis, CancelOption... options) throws IOException;
92140

141+
/**
142+
* Wait {@link Long#MAX_VALUE} msec. for the asynchronous operation to complete uninterruptibly. The attached
143+
* listeners will be notified when the operation is completed.
144+
*
145+
* @return {@code true} if the operation is completed.
146+
* @see #awaitUninterruptibly(long, CancelOption[])
147+
*/
148+
default boolean awaitUninterruptibly() {
149+
return awaitUninterruptibly(new CancelOption[0]);
150+
}
151+
93152
/**
94153
* Wait {@link Long#MAX_VALUE} msec. for the asynchronous operation to complete uninterruptibly. The attached
95154
* listeners will be notified when the operation is completed.
@@ -103,6 +162,18 @@ default boolean awaitUninterruptibly(CancelOption... options) {
103162
return awaitUninterruptibly(Long.MAX_VALUE, options);
104163
}
105164

165+
/**
166+
* Wait for the asynchronous operation to complete with the specified timeout uninterruptibly.
167+
*
168+
* @param timeout The number of time units to wait
169+
* @param unit The {@link TimeUnit} for waiting
170+
* @return {@code true} if the operation is completed.
171+
* @see #awaitUninterruptibly(long, CancelOption[])
172+
*/
173+
default boolean awaitUninterruptibly(long timeout, TimeUnit unit) {
174+
return awaitUninterruptibly(timeout, unit, new CancelOption[0]);
175+
}
176+
106177
/**
107178
* Wait for the asynchronous operation to complete with the specified timeout uninterruptibly.
108179
*
@@ -117,6 +188,16 @@ default boolean awaitUninterruptibly(long timeout, TimeUnit unit, CancelOption..
117188
return awaitUninterruptibly(unit.toMillis(timeout), options);
118189
}
119190

191+
/**
192+
* Wait for the asynchronous operation to complete with the specified timeout uninterruptibly.
193+
*
194+
* @param timeoutMillis Wait time, <code>null</code> to wait forever
195+
* @return {@code true} if the operation is finished.
196+
*/
197+
default boolean awaitUninterruptibly(Duration timeoutMillis) {
198+
return awaitUninterruptibly(timeoutMillis, new CancelOption[0]);
199+
}
200+
120201
/**
121202
* Wait for the asynchronous operation to complete with the specified timeout uninterruptibly.
122203
*
@@ -129,6 +210,16 @@ default boolean awaitUninterruptibly(Duration timeoutMillis, CancelOption... opt
129210
return timeoutMillis != null ? awaitUninterruptibly(timeoutMillis.toMillis(), options) : awaitUninterruptibly(options);
130211
}
131212

213+
/**
214+
* Wait for the asynchronous operation to complete with the specified timeout uninterruptibly.
215+
*
216+
* @param timeoutMillis Wait time in milliseconds
217+
* @return {@code true} if the operation is finished.
218+
*/
219+
default boolean awaitUninterruptibly(long timeoutMillis) {
220+
return awaitUninterruptibly(timeoutMillis, new CancelOption[0]);
221+
}
222+
132223
/**
133224
* Wait for the asynchronous operation to complete with the specified timeout uninterruptibly.
134225
*

0 commit comments

Comments
 (0)