Fix MultiSourceReader compatibility with Java 16+#3670
Merged
bbakerman merged 1 commit intographql-java:masterfrom Jul 23, 2024
Merged
Fix MultiSourceReader compatibility with Java 16+#3670bbakerman merged 1 commit intographql-java:masterfrom
bbakerman merged 1 commit intographql-java:masterfrom
Conversation
bbakerman
reviewed
Jul 23, 2024
| } | ||
| LINE_NUMBER_READER_EOS_IS_TERMINATOR = reader.getLineNumber() > 0; | ||
| } | ||
|
|
bbakerman
approved these changes
Jul 23, 2024
Member
bbakerman
left a comment
There was a problem hiding this comment.
Thanks for this contribution
| throw new UncheckedIOException(e); | ||
| } | ||
| LINE_NUMBER_READER_EOS_IS_TERMINATOR = reader.getLineNumber() > 0; | ||
| } |
Member
There was a problem hiding this comment.
Minor pick - I would encapsulate this into a static method
So you can do
private static final boolean LINE_NUMBER_READER_EOS_IS_TERMINATOR = determineStuff();
Member
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 is a fix for #2709
LineNumberReaderwas updated in Java 16 to consider EOS a line terminator, so if a source doesn't end in newline,getLineNumber()will return 1 + the value in older Java versions. We ran into this issue at Airbnb where we useMultiSourceReaderto read graphqls files. If a schema file didn't end in newline, theSourceLocationfor some types would be incorrect. This PR attempts to address this issue.Testing:
I ran the unit tests with Java 11 and Java 20 (this required bumping the language version in build.gradle) with and without this fix. Without this fix,
LineNumberingTest,MultiSourceReaderTest,ParserExceptionTest,TypeDefinitionRegistryTestfail with Java 20 as described in the open issue. With this fix, they succeed.This also fixed the bug we ran into at Airbnb.