Fix #1190 by marking RequestOptions transient - #1197
Merged
richardm-stripe merged 1 commit intoApr 22, 2021
Conversation
ramon-stripe
force-pushed
the
ramon/20210419-jdk16err
branch
from
April 19, 2021 20:15
2973ada to
8121871
Compare
Also try to prevent similar problems in the future by checking that we only use the reflection-based type adapter for classes in `com.stripe.`.
ramon-stripe
force-pushed
the
ramon/20210419-jdk16err
branch
from
April 19, 2021 21:15
8121871 to
148a5ac
Compare
Contributor
|
r? @ob-stripe would you take a look at this? |
Merged
|
Hello, For information : In the "ReflectionCheckingTypeAdapterFactory" added by this fix, there is the import of "com.google.gson.internal.bind.ReflectiveTypeAdapterFactory" that is "internal" and not exported in the gson Manifest (Export-Package) So in OSGI context, this generate an "Unresolved constraint" error when wiring. |
|
Gson 2.9.1 added a feature which should allow implementing this without having to rely on internal Gson classes. |
This was referenced Dec 20, 2022
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.
cc @stripe/api-libraries
The problem was that Gson was attempting to make certain
java.netclasses constructors accessible through reflection but this is not longer allowed in JDK16 with the default module setup.The reason that Gson was attempting to instantiate these classes was that we forgot to mark the field
StripeCollection.requestOptionstransient(it isn't part of the JSON response). The typeRequestOptionsin turn contains ajava.net.Proxy-type field, which was the source of the problem.I also added
ReflectionCheckingTypeAdapterFactorywhich is a fakeTypeAdapterFactorythat just checks that we aren't using reflection to access anything outside ofcom.stripepackages.In trying to replicate this problem I tried to get this project to build on JDK 16 but that required an upgrade to Gradle 7 which turned out to be too much to put into this PR. The WIP branch for that is here.
Fixes #1190