Replace ReflectionCheckingTypeAdapterFactory with a ReflectionAccessFilter #1496
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.
Notify
r? @stripe/api-library-reviewers
Summary
Fixes #1494
ReflectionCheckingTypeAdapterFactory
-- this should be non breaking as the visibility is package-private.ReflectionAccessFilter
(new in Gson 2.9.1) as a replacement.I have NOT actually set up a project to reproduce #1494, but I am still highly confident this will fix it as it is completely removing the class with the suspect import statement.
Context
Basically, we want to throw an exception when GSON is asked to use reflection and deserialize a class that isn't beneath
com.stripe.
, usually this happens when the class has an "infrastructure" field that doesn't represent data, but the field is not marked "transient", e.g. in #1197 the issue was thatStripeCollection
had aprivate RequestOptions requestOptions
that should have beenprivate transient RequestOptions requestOptions
. ("transient" is a Java keyword that means "shouldn't be serialized"). TheReflectionCheckingTypeAdapter
was added to give a better error message and help prevent us from making mistakes like this again (the error message in #1190 is pretty hard to interpret), but theReflectionAccessFilter
should do the same thing without causing the module path issues mentioned in #1494.