Skip to content

Commit

Permalink
[hotfix] Remove redundant FutureUtils#getFailedFuture
Browse files Browse the repository at this point in the history
FutureUtils#completedExceptionally does exactly the same.
  • Loading branch information
tillrohrmann committed Oct 30, 2017
1 parent 152f6c9 commit 747cf82
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ private CompletableFuture<KvStateResponse> getState(

final InetSocketAddress serverAddress = location.getKvStateServerAddress(keyGroupIndex);
if (serverAddress == null) {
return FutureUtils.getFailedFuture(new UnknownKvStateKeyGroupLocationException(getServerName()));
return FutureUtils.completedExceptionally(new UnknownKvStateKeyGroupLocationException(getServerName()));
} else {
// Query server
final KvStateID kvStateId = location.getKvStateID(keyGroupIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
public class KvStateClientProxyImpl extends AbstractServerBase<KvStateRequest, KvStateResponse> implements KvStateClientProxy {

private static final CompletableFuture<ActorGateway> UNKNOWN_JOB_MANAGER =
FutureUtils.getFailedFuture(new UnknownJobManagerException());
FutureUtils.completedExceptionally(new UnknownJobManagerException());

/** Number of threads used to process incoming requests. */
private final int queryExecutorThreads;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,20 +445,4 @@ public void onComplete(Throwable failure, T success) throws Throwable {

return result;
}

// ------------------------------------------------------------------------
// Future Completed with an exception.
// ------------------------------------------------------------------------

/**
* Returns a {@link CompletableFuture} that has failed with the exception
* provided as argument.
* @param throwable the exception to fail the future with.
* @return The failed future.
*/
public static <T> CompletableFuture<T> getFailedFuture(Throwable throwable) {
CompletableFuture<T> failedAttempt = new CompletableFuture<>();
failedAttempt.completeExceptionally(throwable);
return failedAttempt;
}
}

0 comments on commit 747cf82

Please sign in to comment.