Skip to content

one instrustumentation callback method - #593

Merged
bbakerman merged 11 commits into
graphql-java:masterfrom
bbakerman:592-one-instrustrmentation-callback-method
Aug 8, 2017
Merged

bbakerman merged 11 commits into
graphql-java:masterfrom
bbakerman:592-one-instrustrmentation-callback-method

Conversation

@bbakerman

Copy link
Copy Markdown
Member

See #592

@bbakerman bbakerman added the breaking change requires a new major version to be relased label Aug 2, 2017
@bbakerman bbakerman added this to the 4.0.0 milestone Aug 2, 2017
@bbakerman
bbakerman requested review from andimarek and kaqqao August 2, 2017 10:10
@kaqqao

kaqqao commented Aug 2, 2017 •

Copy link
Copy Markdown
Contributor

The code seems fine, so if you're sure the design is sound, it's all good.

I have some doubts myself... I'm having issues understanding the implications of replacing thenApply/thenAccept with handle/whenComplete. Does it mean the exceptional completion was previously not triggering the instrumentation context callback when it should have? In this new impl. it seems safe, thus the new design seems better...
But if I misunderstood this, and the difference is just 1 vs 2 finisher methods, I must say I prefer having 2 with clear purpose, rather than one with mixed purpose. But I don't have strong opinions there.

@bbakerman

Copy link
Copy Markdown
Member Author

thenApply / thenAccept are the forms where you ONLY get the successful value. The exception will be thrown when you to CF.get()

handle / whenComplete are the forms that area BiFunction/BiConsumer that are given the success value OR the throwable both at the same time

The equate to the same thing in practice but the error path is now made visible

@kaqqao kaqqao left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old code still looks wrong to me... See this line, the executionInstrumentation created there never seems to be called with an exception, i.e. executionInstrumentation.onEnd(exception).
Same for the context created here.
In your new code, it looks correct in all cases.

Even further, since CompletableFuture doesn't even seem to have a callback for exceptional completion only, your approach seems to be literally the only valid one. As such, I'd say definitely merge this.

@kaqqao kaqqao mentioned this pull request Aug 7, 2017
@bbakerman
bbakerman merged commit a666d0d into graphql-java:master Aug 8, 2017
huangd0ng pushed a commit to dayuwuxian/graphql-java that referenced this pull request Aug 29, 2017
* Fixed javadoc warning

* Made the instrumentation callback one method to suit lambdas and be easily to implement

* Now with new method shape

* fixed shape of chained code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change requires a new major version to be relased

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants