Skip to content

Commit 4b09af0

Browse files
garydgregoryok2c
authored andcommitted
A FutureContribution should not allow a null BasicFuture (#485)
1 parent aca2fc9 commit 4b09af0

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

httpcore5/src/main/java/org/apache/hc/core5/concurrent/FutureContribution.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
*/
2727
package org.apache.hc.core5.concurrent;
2828

29+
import java.util.Objects;
30+
2931
/**
3032
* Convenience base class for {@link FutureCallback}s that contribute a result
3133
* of the operation to another {@link BasicFuture}.
@@ -40,24 +42,20 @@ public abstract class FutureContribution<T> implements FutureCallback<T> {
4042
/**
4143
* Constructs a new instance to callback the given {@link BasicFuture}.
4244
*
43-
* @param future The callback.
45+
* @param future The callback, non-null.
4446
*/
4547
public FutureContribution(final BasicFuture<?> future) {
46-
this.future = future;
48+
this.future = Objects.requireNonNull(future);
4749
}
4850

4951
@Override
5052
public final void failed(final Exception ex) {
51-
if (future != null) {
52-
future.failed(ex);
53-
}
53+
future.failed(ex);
5454
}
5555

5656
@Override
5757
public final void cancelled() {
58-
if (future != null) {
59-
future.cancel();
60-
}
58+
future.cancel();
6159
}
6260

6361
@SuppressWarnings("unchecked")

0 commit comments

Comments
 (0)