avoid wrapping materialized fieldValueObject in a CompletableFuture#3943
Merged
bbakerman merged 1 commit intographql-java:masterfrom Apr 30, 2025
Merged
Conversation
samuelAndalon
commented
Apr 29, 2025
| CompletableFuture<Object> executionResultFuture = fieldValueInfo.getFieldValueFuture(); | ||
| ctxCompleteField.onDispatched(); | ||
| executionResultFuture.whenComplete(ctxCompleteField::onCompleted); | ||
| if (fieldValueInfo.isFutureValue()) { |
Author
There was a problem hiding this comment.
I could've done this as well but it has the unchecked cast already handled internally by FieldValueInfo
Object executionResult = fieldValueInfo.getFieldValueObject();
ctxCompleteField.onDispatched();
if (executionResult instanceof CompletableFuture) {
@SuppressWarnings("unchecked")
CompletableFuture<Object> executionResultFuture = (CompletableFuture<Object>) executionResult;
executionResultFuture.whenComplete(ctxCompleteField::onCompleted);
} else {
ctxCompleteField.onCompleted(executionResult, null);
}
Samjin
approved these changes
Apr 29, 2025
bbakerman
approved these changes
Apr 29, 2025
Member
bbakerman
left a comment
There was a problem hiding this comment.
Nice catch - I am embarrassed I missed this in the great "materialised migration" effort
Author
|
all good! thank you, now I am curious the memory and CPU improvement this change will bring |
Author
|
@bbakerman I wonder if this can be cherry picked to version 22.x ? I can prepare the PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While updating graphql-kotlin to graphql-java 23 found that
completeFieldis still wrappingFieldValueInfo.fieldValueObjectin aCompletableFuturefor objects already materialized / in memorythis might be considered a follow up of the
Completable Future wrappingchange set that came in graphql-java 22https://github.com/graphql-java/graphql-java/releases/tag/v22.0
I don't think this is a breaking change.