Repository navigation
Conversation
| private void skipQuotedValue(char quote) throws IOException { | ||
| if (strictness == Strictness.STRICT) { | ||
| // Read the value so that the same validation as for nextString() and nextName() is applied | ||
| String unused = nextQuotedValue(quote); |
Author
There was a problem hiding this comment.
I think this one's a false positive. com.google.gson.stream is annotated @CheckReturnValue, so the result of nextQuotedValue has to be assigned to something, and unused is the Error Prone convention for intentionally discarding it. It's the same shape as char unused = readEscapeCharacter() a few lines further down in this same method, and int unused = nextNonWhitespace(true) elsewhere in the file. Dropping the assignment would fail the build, and CodeQL's unread-local-variable query doesn't honor @SuppressWarnings("unused") either, so there isn't much to change on my side. Happy to adjust if you'd rather I avoid materializing the string on the skip path.
This branch has not been deployed
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.
Purpose
In
Strictness.STRICT, unescaped control characters and unpaired surrogates (#3116) are only rejected innextQuotedValue, soskipValue()still accepts them. A strictGsontherefore accepts{"a":"x<TAB>y","b":1}or{"a":"\uD800","b":1}when deserializing into a class without fielda, while the same input is rejected whenais read.Description
In strict mode
skipQuotedValuenow reads the string throughnextQuotedValue, so skipped values and names get the same checks asnextString()andnextName(). Legacy strict and lenient modes keep the existing fast skip path.Checklist
This is automatically checked by
mvn verify, but can also be checked on its own usingmvn spotless:check.Style violations can be fixed using
mvn spotless:apply; this can be done in a separate commit to verify that it did not cause undesired changes.null@since $next-version$(
$next-version$is a special placeholder which is automatically replaced during release)TestCase)mvn clean verify javadoc:jarpasses without errors