Skip to content

Commit

Permalink
FailedFuture should always have a cause even when the provided cause …
Browse files Browse the repository at this point in the history
…is null - fixes #1910
  • Loading branch information
vietj committed Mar 28, 2017
1 parent 4855ffb commit 17b8658
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 28 deletions.
16 changes: 12 additions & 4 deletions src/main/java/io/vertx/core/impl/FailedFuture.java
Expand Up @@ -26,10 +26,18 @@ public class FailedFuture<T> implements Future<T> {


private final Throwable cause; private final Throwable cause;


FailedFuture(Throwable cause) { /**
this.cause = cause; * Create a future that has already failed
} * @param t the throwable

*/
FailedFuture(Throwable t) {
cause = t != null ? t : new NoStackTraceThrowable(null);
}

/**
* Create a future that has already failed
* @param failureMessage the failure message
*/
FailedFuture(String failureMessage) { FailedFuture(String failureMessage) {
this(new NoStackTraceThrowable(failureMessage)); this(new NoStackTraceThrowable(failureMessage));
} }
Expand Down
24 changes: 0 additions & 24 deletions src/main/java/io/vertx/core/impl/FutureImpl.java
Expand Up @@ -33,30 +33,6 @@ class FutureImpl<T> implements Future<T>, Handler<AsyncResult<T>> {
FutureImpl() { FutureImpl() {
} }


/**
* Create a future that has already failed
* @param t the throwable
*/
FutureImpl(Throwable t) {
fail(t != null ? t : new NoStackTraceThrowable(null));
}

/**
* Create a future that has already failed
* @param failureMessage the failure message
*/
FutureImpl(String failureMessage) {
this(new NoStackTraceThrowable(failureMessage));
}

/**
* Create a future that has already succeeded
* @param result the result
*/
FutureImpl(T result) {
complete(result);
}

/** /**
* The result of the operation. This will be null if the operation failed. * The result of the operation. This will be null if the operation failed.
*/ */
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/io/vertx/core/impl/SucceededFuture.java
Expand Up @@ -26,6 +26,10 @@ class SucceededFuture<T> implements Future<T> {


private final T result; private final T result;


/**
* Create a future that has already succeeded
* @param result the result
*/
SucceededFuture(T result) { SucceededFuture(T result) {
this.result = result; this.result = result;
} }
Expand Down

0 comments on commit 17b8658

Please sign in to comment.