Explicitly allow null into CompletableResultCode.failExceptionally() (#6963)
This commit is contained in:
parent
40b74b05e1
commit
c1b9ec789c
|
@ -123,9 +123,10 @@ public final class CompletableResultCode {
|
|||
* Completes this {@link CompletableResultCode} unsuccessfully if it is not already completed,
|
||||
* setting the {@link #getFailureThrowable() failure throwable} to {@code throwable}.
|
||||
*
|
||||
* @param throwable the {@code Throwable} that caused the failure, or {@code null}
|
||||
* @since 1.41.0
|
||||
*/
|
||||
public CompletableResultCode failExceptionally(Throwable throwable) {
|
||||
public CompletableResultCode failExceptionally(@Nullable Throwable throwable) {
|
||||
return failInternal(throwable);
|
||||
}
|
||||
|
||||
|
@ -160,7 +161,8 @@ public final class CompletableResultCode {
|
|||
* via the {@link #whenComplete(Runnable)} method.
|
||||
*
|
||||
* @return the throwable if failed exceptionally, or null if: {@link #fail() failed without
|
||||
* exception}, {@link #succeed() succeeded}, or not complete.g
|
||||
* exception}, {@link #succeed() succeeded}, {@link #failExceptionally(Throwable)} with a null
|
||||
* {@code throwable}, or not complete.
|
||||
* @since 1.41.0
|
||||
*/
|
||||
@Nullable
|
||||
|
|
|
@ -79,6 +79,15 @@ class CompletableResultCodeTest {
|
|||
assertThat(resultCode.isSuccess()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void failExceptionallyWithNull() {
|
||||
CompletableResultCode resultCode = new CompletableResultCode();
|
||||
CompletableResultCode result = resultCode.failExceptionally(null);
|
||||
assertThat(result.isDone()).isTrue();
|
||||
assertThat(result.isSuccess()).isFalse();
|
||||
assertThat(result.getFailureThrowable()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenDoublyCompleteSuccessfully() throws InterruptedException {
|
||||
CompletableResultCode resultCode = new CompletableResultCode();
|
||||
|
|
Loading…
Reference in New Issue