Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly allow null into CompletableResultCode.failExceptionally() #6963

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,10 @@ public CompletableResultCode fail() {
* 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) {
breedx-splk marked this conversation as resolved.
Show resolved Hide resolved
return failInternal(throwable);
}

Expand Down Expand Up @@ -160,7 +161,8 @@ public boolean isSuccess() {
* 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ void fail() throws InterruptedException {
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();
Expand Down
Loading