Skip to content

Commit d51dbfb

Browse files
committed
Remove Future checks in GraphQlHttpHandler
Closes gh-1152
1 parent 285dcda commit d51dbfb

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

spring-graphql/src/main/java/org/springframework/graphql/server/webmvc/GraphQlHttpHandler.java

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818

1919
import java.util.List;
2020
import java.util.Map;
21-
import java.util.concurrent.CompletableFuture;
22-
import java.util.concurrent.ExecutionException;
2321

2422
import reactor.core.publisher.Mono;
2523

@@ -106,7 +104,7 @@ public void setHttpOkOnValidationErrors(boolean httpOkOnValidationErrors) {
106104
@Override
107105
protected ServerResponse prepareResponse(ServerRequest request, Mono<WebGraphQlResponse> responseMono) {
108106

109-
CompletableFuture<ServerResponse> future = responseMono.map((response) -> {
107+
Mono<ServerResponse> mono = responseMono.map((response) -> {
110108
MediaType contentType = selectResponseMediaType(request);
111109
HttpStatus responseStatus = selectResponseStatus(response, contentType);
112110
ServerResponse.BodyBuilder builder = ServerResponse.status(responseStatus);
@@ -116,21 +114,9 @@ protected ServerResponse prepareResponse(ServerRequest request, Mono<WebGraphQlR
116114
Map<String, Object> resultMap = response.toMap();
117115
ServerResponse.HeadersBuilder.WriteFunction writer = getWriteFunction(resultMap, contentType);
118116
return (writer != null) ? builder.build(writer) : builder.body(resultMap);
119-
}).toFuture();
117+
});
120118

121-
// This won't be needed on a Spring Framework 6.2 baseline:
122-
// https://github.com/spring-projects/spring-framework/issues/32223
123-
124-
if (future.isDone() && !future.isCancelled() && !future.isCompletedExceptionally()) {
125-
try {
126-
return future.get();
127-
}
128-
catch (InterruptedException | ExecutionException ignored) {
129-
// fall through to use DefaultAsyncServerResponse
130-
}
131-
}
132-
133-
return ServerResponse.async(future);
119+
return ServerResponse.async(mono.toFuture());
134120
}
135121

136122
protected HttpStatus selectResponseStatus(WebGraphQlResponse response, MediaType responseMediaType) {

0 commit comments

Comments
 (0)