FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix MultiSourceReader compatibility with Java 16+ by gummybug · Pull Request #3670 · graphql-java/graphql-java · GitHub

Fix MultiSourceReader compatibility with Java 16+ - #3670

Merged
bbakerman merged 1 commit into
graphql-java:masterfrom
gummybug:multisource-reader-java-16
Jul 23, 2024
Merged

Fix MultiSourceReader compatibility with Java 16+#3670
bbakerman merged 1 commit into
graphql-java:masterfrom
gummybug:multisource-reader-java-16

Conversation

gummybug commented Jul 22, 2024
edited
Loading

Copy link
Copy Markdown

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 use MultiSourceReader to read graphqls files. If a schema file didn't end in newline, the SourceLocation 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.

}
LINE_NUMBER_READER_EOS_IS_TERMINATOR = reader.getLineNumber() > 0;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Clever!

bbakerman added this to the 22.2: non-breaking changes milestone Jul 23, 2024

bbakerman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks for this contribution

throw new UncheckedIOException(e);
}
LINE_NUMBER_READER_EOS_IS_TERMINATOR = reader.getLineNumber() > 0;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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();

bbakerman added this pull request to the merge queue Jul 23, 2024
Merged via the queue into graphql-java:master with commit e933832 Jul 23, 2024

dondonz commented Jul 23, 2024

Copy link
Copy Markdown
Member

Thanks for this PR!

Leaving a link for later, this issue was reported a while back #2709 with a related suggestion to run tests on different Java versions to catch these issues earlier #2789. Might be time to look into different Java versions for our tests again. Thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL