Fix MultiSourceReader compatibility with Java 16+ #3670
Merged
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
LineNumberReader
was 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 useMultiSourceReader
to read graphqls files. If a schema file didn't end in newline, theSourceLocation
for 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
,TypeDefinitionRegistryTest
fail with Java 20 as described in the open issue. With this fix, they succeed.This also fixed the bug we ran into at Airbnb.