Skip to content

Commit

Permalink
Modify AsyncResponseHandler.handleResponse method signature
Browse files Browse the repository at this point in the history
  • Loading branch information
wplong11 committed Oct 10, 2022
1 parent 72536a7 commit 4304656
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
11 changes: 11 additions & 0 deletions core/src/main/java/feign/AsyncResponseHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ public AsyncResponseHandler(Level logLevel, Logger logger, Decoder decoder,
responseInterceptor);
}

public CompletableFuture<Object> handleResponse(
String configKey, Response response, Type returnType, long elapsedTime) {
CompletableFuture<Object> resultFuture = new CompletableFuture<>();
handleResponse(resultFuture, configKey, response, returnType, elapsedTime);
return resultFuture;
}

/**
* @deprecated use {@link #handleResponse(String, Response, Type, long)} instead.
*/
@Deprecated()
public void handleResponse(CompletableFuture<Object> resultFuture,
String configKey,
Response response,
Expand Down
12 changes: 2 additions & 10 deletions core/src/main/java/feign/AsynchronousMethodHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,8 @@ private static Response ensureRequestIsSet(Response response,
}

private CompletableFuture<Object> handleResponse(Response response, long elapsedTime) {
CompletableFuture<Object> resultFuture = new CompletableFuture<>();

asyncResponseHandler.handleResponse(resultFuture, metadata.configKey(), response,
methodInfo.underlyingReturnType(), elapsedTime);

if (!resultFuture.isDone()) {
resultFuture.completeExceptionally(new IllegalStateException("Response handling not done"));
}

return resultFuture;
return asyncResponseHandler.handleResponse(
metadata.configKey(), response, methodInfo.underlyingReturnType(), elapsedTime);
}

private long elapsedTime(long start) {
Expand Down

0 comments on commit 4304656

Please sign in to comment.