Since the Strictness API (#2323) has not been released yet, we can fix the parsing of JsonParser in the same backward compatible way we fixed it for the Gson methods:
If the strictness is LEGACY_STRICT (the default) we parse with LENIENT
But if the user has explicitly set STRICT (which will only be possible now with the Strictness API) we respect this setting and parse in strict mode
This pull request also changes the getStrictness() == Strictness.LEGACY_STRICT checks in Gson to make the intention clearer that this is for backward compatibility. Behavior-wise they still act like before:
LENIENT -> LENIENT (but is not explicitly overwritten anymore now)
LEGACY_STRICT -> LENIENT
STRICT -> STRICT
Checklist
[x] New code follows the Google Java Style Guide\
This is automatically checked by mvn verify, but can also be checked on its own using mvn 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.
[ ] If necessary, new public API validates arguments, for example rejects null
[ ] New public API has Javadoc
[ ] Javadoc uses @since $next-version$
($next-version$ is a special placeholder which is automatically replaced during release)
[x] If necessary, new unit tests have been added
[x] Assertions in unit tests use Truth, see existing tests
[x] No JUnit 3 features are used (such as extending class TestCase)
[x] If this pull request fixes a bug, a new test was added for a situation which failed previously and is now fixed
[x] mvn clean verify javadoc:jar passes without errors
Purpose
Support strict parsing for
JsonParser
Description
Since the
Strictness
API (#2323) has not been released yet, we can fix the parsing ofJsonParser
in the same backward compatible way we fixed it for theGson
methods:LEGACY_STRICT
(the default) we parse withLENIENT
STRICT
(which will only be possible now with theStrictness
API) we respect this setting and parse in strict modeThis pull request also changes the
getStrictness() == Strictness.LEGACY_STRICT
checks inGson
to make the intention clearer that this is for backward compatibility. Behavior-wise they still act like before:LENIENT
->LENIENT
(but is not explicitly overwritten anymore now)LEGACY_STRICT
->LENIENT
STRICT
->STRICT
Checklist
mvn verify
, but can also be checked on its own usingmvn spotless:check
.\ Style violations can be fixed usingmvn 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:jar
passes without errors