aboutsummaryrefslogtreecommitdiff
path: root/okhttp
diff options
context:
space:
mode:
authorzpencer <spencerfang@google.com>2018-02-08 08:57:52 -0800
committerGitHub <noreply@github.com>2018-02-08 08:57:52 -0800
commitf8c7f963efb441cee24f94ffc97aeb642a0a1c9c (patch)
treeaf5cafc894cc795291bcd63885a655d6814a2b96 /okhttp
parentc735bb338532282069f3915894e99d730584f475 (diff)
downloadgrpc-grpc-java-f8c7f963efb441cee24f94ffc97aeb642a0a1c9c.tar.gz
core,netty,okhttp: use ServiceProviders for ManagedChannelProvider, ServerProvider (#4047)
Diffstat (limited to 'okhttp')
-rw-r--r--okhttp/src/main/java/io/grpc/okhttp/OkHttpChannelProvider.java4
-rw-r--r--okhttp/src/test/java/io/grpc/okhttp/OkHttpChannelProviderTest.java8
2 files changed, 9 insertions, 3 deletions
diff --git a/okhttp/src/main/java/io/grpc/okhttp/OkHttpChannelProvider.java b/okhttp/src/main/java/io/grpc/okhttp/OkHttpChannelProvider.java
index 4c87b7f0f..7fb888d1e 100644
--- a/okhttp/src/main/java/io/grpc/okhttp/OkHttpChannelProvider.java
+++ b/okhttp/src/main/java/io/grpc/okhttp/OkHttpChannelProvider.java
@@ -17,6 +17,7 @@
package io.grpc.okhttp;
import io.grpc.Internal;
+import io.grpc.InternalServiceProviders;
import io.grpc.ManagedChannelProvider;
import io.grpc.internal.GrpcUtil;
@@ -33,7 +34,8 @@ public final class OkHttpChannelProvider extends ManagedChannelProvider {
@Override
public int priority() {
- return (GrpcUtil.IS_RESTRICTED_APPENGINE || isAndroid()) ? 8 : 3;
+ return (GrpcUtil.IS_RESTRICTED_APPENGINE
+ || InternalServiceProviders.isAndroid(getClass().getClassLoader())) ? 8 : 3;
}
@Override
diff --git a/okhttp/src/test/java/io/grpc/okhttp/OkHttpChannelProviderTest.java b/okhttp/src/test/java/io/grpc/okhttp/OkHttpChannelProviderTest.java
index 6a2ef7f37..94e48dcc9 100644
--- a/okhttp/src/test/java/io/grpc/okhttp/OkHttpChannelProviderTest.java
+++ b/okhttp/src/test/java/io/grpc/okhttp/OkHttpChannelProviderTest.java
@@ -20,6 +20,8 @@ import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import io.grpc.InternalManagedChannelProvider;
+import io.grpc.InternalServiceProviders;
import io.grpc.ManagedChannelProvider;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -33,7 +35,8 @@ public class OkHttpChannelProviderTest {
@Test
public void provided() {
for (ManagedChannelProvider current
- : ManagedChannelProvider.getCandidatesViaServiceLoader(getClass().getClassLoader())) {
+ : InternalServiceProviders.getCandidatesViaServiceLoader(
+ ManagedChannelProvider.class, getClass().getClassLoader())) {
if (current instanceof OkHttpChannelProvider) {
return;
}
@@ -43,7 +46,8 @@ public class OkHttpChannelProviderTest {
@Test
public void providedHardCoded() {
- for (ManagedChannelProvider current : ManagedChannelProvider.getCandidatesViaHardCoded()) {
+ for (ManagedChannelProvider current : InternalServiceProviders.getCandidatesViaHardCoded(
+ ManagedChannelProvider.class, InternalManagedChannelProvider.HARDCODED_CLASSES)) {
if (current instanceof OkHttpChannelProvider) {
return;
}