-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
okhttp: make okhttp dependencies compile only #8971
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll need to take a closer look, but at first glance this looks perfect. I am sorry, I had been intending to do the third_party copies, but glad you figured it out. Also sorry that it didn't see review earlier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very easy to review. Thank you. Code looks good.
I need to figure out what's wrong with the Android CI. It doesn't seem likely to be a flake.
Error from Android CI.
Hmm... getMethod() calls getDeclaredMethods0(). That means we can't do any reflection on the class? We could workaround the problem by adding okhttp as a dependency of grpc-android. We could also use a different class for the reflection; OkHttpChannelProvider would be a good candidate. Let's avoid this problem in this PR, so we can make forward progress. Let's keep okhttp as an API dependency in this PR. Today I'll try changing the reflection to OkHttpChannelProvider. |
Doing any reflection on OkHttpChannelBuilder requires that all methods can have their arguments resolved. We'd like to make okhttp an optional dependency (to support okhttp 2 and 3/4 simultaneously). But making okhttp optional means we can no longer construct OkHttpChannelBuilder reflectively. We swap to the Provider that doesn't have this problem. See grpc#8971. Note that ManagedChannelProvider itself only exposes its methods as protected, so they wouldn't be accessible. However OkHttpChannelProvider has its methods public. It is an open question of whether ManagedChannelProvider's methods should become public, but in any case we can hide a public OkHttpChannelProvider inside a package-private class so it is only accessable via reflection. So this code assuming public methods doesn't prevent future implementation hiding.
Doing any reflection on OkHttpChannelBuilder requires that all methods can have their arguments resolved. We'd like to make okhttp an optional dependency (to support okhttp 2 and 3/4 simultaneously). But making okhttp optional means we can no longer construct OkHttpChannelBuilder reflectively. We swap to the Provider that doesn't have this problem. See grpc#8971. Note that ManagedChannelProvider itself only exposes its methods as protected, so they wouldn't be accessible. However OkHttpChannelProvider has its methods public. It is an open question of whether ManagedChannelProvider's methods should become public, but in any case we can hide a public OkHttpChannelProvider inside a package-private class so it is only accessable via reflection. So this code assuming public methods doesn't prevent future implementation hiding.
Doing any reflection on OkHttpChannelBuilder requires that all methods can have their arguments resolved. We'd like to make okhttp an optional dependency (to support okhttp 2 and 3/4 simultaneously). But making okhttp optional means we can no longer construct OkHttpChannelBuilder reflectively. We swap to the Provider that doesn't have this problem. See grpc#8971. Note that ManagedChannelProvider itself only exposes its methods as protected, so they wouldn't be accessible. However OkHttpChannelProvider has its methods public. It is an open question of whether ManagedChannelProvider's methods should become public, but in any case we can hide a public OkHttpChannelProvider inside a package-private class so it is only accessable via reflection. So this code assuming public methods doesn't prevent future implementation hiding.
Doing any reflection on OkHttpChannelBuilder requires that all methods can have their arguments resolved. We'd like to make okhttp an optional dependency (to support okhttp 2 and 3/4 simultaneously). But making okhttp optional means we can no longer construct OkHttpChannelBuilder reflectively. We swap to the Provider that doesn't have this problem. See grpc#8971. Note that ManagedChannelProvider itself only exposes its methods as protected, so they wouldn't be accessible. However OkHttpChannelProvider has its methods public. It is an open question of whether ManagedChannelProvider's methods should become public, but in any case we can hide a public OkHttpChannelProvider inside a package-private class so it is only accessable via reflection. So this code assuming public methods doesn't prevent future implementation hiding.
CC @YifeiZhuang, @temawi |
@beatrausch, actually. You can hold-off. We can just make sure my PR goes in first. Changing this PR now would mean changing the PR title and some other stuff. It turned out I made my changes quickly, so this is probably fine as-is. |
Ok |
Doing any reflection on OkHttpChannelBuilder requires that all methods can have their arguments resolved. We'd like to make okhttp an optional dependency (to support okhttp 2 and 3/4 simultaneously). But making okhttp optional means we can no longer construct OkHttpChannelBuilder reflectively. We swap to the Provider that doesn't have this problem. See #8971. Note that ManagedChannelProvider itself only exposes its methods as protected, so they wouldn't be accessible. However OkHttpChannelProvider has its methods public. It is an open question of whether ManagedChannelProvider's methods should become public, but in any case we can hide a public OkHttpChannelProvider inside a package-private class so it is only accessable via reflection. So this code assuming public methods doesn't prevent future implementation hiding.
#9003 is merged. Re-running the Android CI. |
@YifeiZhuang, could you take a look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…)" This partly reverts b20ce17 because it is dependent on cda0e9d which is being reverted as it is incompatible with Proguard without configuration (e.g., isAvailable() may not be available and would need a -keep). While the code no longer uses compileOnly, the compatibility still remains, so it would be possible for users to exclude the okhttp dependency if they don't use AndroidChannelBuilder.
Doing any reflection on OkHttpChannelBuilder requires that all methods can have their arguments resolved. We'd like to make okhttp an optional dependency (to support okhttp 2 and 3/4 simultaneously). But making okhttp optional means we can no longer construct OkHttpChannelBuilder reflectively. We swap to the Provider that doesn't have this problem. See grpc#8971. Note that ManagedChannelProvider itself only exposes its methods as protected, so they wouldn't be accessible. However OkHttpChannelProvider has its methods public. It is an open question of whether ManagedChannelProvider's methods should become public, but in any case we can hide a public OkHttpChannelProvider inside a package-private class so it is only accessable via reflection. So this code assuming public methods doesn't prevent future implementation hiding.
* okhttp: forked required files to make okhttp dep compile only * okhttp: forked missing file to make okhttp dep compile only * okhttp: moved url and request files to proxy packge * okhttp: removed unused methods from forked files; fixed build
This PR makes okhttp dependencies compile only. The PR is related to #6119 #8732 and is the base to add okhttp3 in the public API. For the implementation the required okhttp2 files had been forked.