Make the graphql-java Asserts truly lazy and hence more efficient#1913
Merged
Conversation
…nto klee97-lazyAssert
It takes it much further and makes them ALL lazy in their message retrieval and encourages efficient asserts by not providing the string.format rope with which to hang yourself. We now require that a supplier be provided to asserts that want messages to be thrown
bbakerman
commented
May 21, 2020
| @@ -1,25 +1,26 @@ | |||
| package graphql; | |||
Member
Author
There was a problem hiding this comment.
This is the KEY file changed and its test.
The others are all knock on effects
bbakerman
commented
May 21, 2020
| return; | ||
| } | ||
| throw new AssertException("condition expected to be false"); | ||
| } |
Member
Author
There was a problem hiding this comment.
The above was missing but present for assertTrue so I made it
Member
Author
There was a problem hiding this comment.
assertShouldNeverHappen can be as slow as it likes - its ALWAYS going to assert.
I mean we could make it a supplier based on consistency but....I thought its ok to leave it
andimarek
approved these changes
May 21, 2020
andimarek
left a comment
Member
There was a problem hiding this comment.
What about assertShouldNeverHappen?
# Conflicts: # src/main/java/graphql/ExecutionInput.java
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.
This means all asserts will be encouraged to be efficient by default.
It not longer possible to write an accidental slow one even if you do
because it wont compile.
it must now be
I have commented on the actually changed files that matter.
This is technically not a breaking API change because it was marked as @internal. However its likely people have used it - well that's what @internal is there to warn people about. Soz but we reserve the right with a reason nad this is one of those reasons.
See #1876 for the original problem - this takes it much further