diff --git a/android/src/main/java/io/grpc/android/AndroidChannelBuilder.java b/android/src/main/java/io/grpc/android/AndroidChannelBuilder.java index 0b549164fb..5baa6c2cd4 100644 --- a/android/src/main/java/io/grpc/android/AndroidChannelBuilder.java +++ b/android/src/main/java/io/grpc/android/AndroidChannelBuilder.java @@ -39,7 +39,7 @@ import io.grpc.okhttp.NegotiationType; import io.grpc.okhttp.OkHttpChannelBuilder; import java.util.List; -import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executor; /** * A {@link io.grpc.ManagedChannelBuilder} that provides a stable interface for producing @@ -77,7 +77,7 @@ public class AndroidChannelBuilder extends ManagedChannelBuilder> *

The channel won't take ownership of the given executor. It's caller's responsibility to * shut down the executor when it's desired. */ - public abstract T executor(ExecutorService executor); + public abstract T executor(Executor executor); /** * Adds interceptors that will be called before the channel performs its real work. This is diff --git a/core/src/main/java/io/grpc/ServerBuilder.java b/core/src/main/java/io/grpc/ServerBuilder.java index a8e2902ad2..60a6d612ed 100644 --- a/core/src/main/java/io/grpc/ServerBuilder.java +++ b/core/src/main/java/io/grpc/ServerBuilder.java @@ -31,7 +31,7 @@ package io.grpc; -import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executor; import javax.annotation.Nullable; @@ -50,7 +50,7 @@ public abstract class ServerBuilder> { *

The server won't take ownership of the given executor. It's caller's responsibility to * shut down the executor when it's desired. */ - public abstract T executor(@Nullable ExecutorService executor); + public abstract T executor(@Nullable Executor executor); /** * Adds a service implementation to the handler registry. diff --git a/core/src/main/java/io/grpc/internal/AbstractManagedChannelImplBuilder.java b/core/src/main/java/io/grpc/internal/AbstractManagedChannelImplBuilder.java index dd81e130df..5097c9fc24 100644 --- a/core/src/main/java/io/grpc/internal/AbstractManagedChannelImplBuilder.java +++ b/core/src/main/java/io/grpc/internal/AbstractManagedChannelImplBuilder.java @@ -38,7 +38,7 @@ import io.grpc.ManagedChannelBuilder; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executor; import javax.annotation.Nullable; @@ -51,14 +51,14 @@ public abstract class AbstractManagedChannelImplBuilder > extends ManagedChannelBuilder { @Nullable - private ExecutorService executor; + private Executor executor; private final List interceptors = new ArrayList(); @Nullable private String userAgent; @Override - public final T executor(ExecutorService executor) { + public final T executor(Executor executor) { this.executor = executor; return thisT(); } diff --git a/core/src/main/java/io/grpc/internal/AbstractServerImplBuilder.java b/core/src/main/java/io/grpc/internal/AbstractServerImplBuilder.java index d2249128ca..7fb2a7fc62 100644 --- a/core/src/main/java/io/grpc/internal/AbstractServerImplBuilder.java +++ b/core/src/main/java/io/grpc/internal/AbstractServerImplBuilder.java @@ -40,7 +40,7 @@ import io.grpc.MutableHandlerRegistryImpl; import io.grpc.ServerBuilder; import io.grpc.ServerServiceDefinition; -import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executor; import javax.annotation.Nullable; @@ -54,7 +54,7 @@ public abstract class AbstractServerImplBuilder interceptors) { this.transportFactory = transportFactory; this.userAgent = userAgent; @@ -387,7 +387,7 @@ public final class ManagedChannelImpl extends ManagedChannel { */ private void onChannelTerminated() { if (usingSharedExecutor) { - SharedResourceHolder.release(GrpcUtil.SHARED_CHANNEL_EXECUTOR, executor); + SharedResourceHolder.release(GrpcUtil.SHARED_CHANNEL_EXECUTOR, (ExecutorService) executor); } // Release the transport factory so that it can deallocate any resources. transportFactory.release(); diff --git a/okhttp/src/main/java/io/grpc/okhttp/OkHttpChannelBuilder.java b/okhttp/src/main/java/io/grpc/okhttp/OkHttpChannelBuilder.java index 712881dbdc..70097a4ca3 100644 --- a/okhttp/src/main/java/io/grpc/okhttp/OkHttpChannelBuilder.java +++ b/okhttp/src/main/java/io/grpc/okhttp/OkHttpChannelBuilder.java @@ -49,6 +49,7 @@ import io.grpc.internal.ClientTransportFactory; import io.grpc.internal.SharedResourceHolder; import io.grpc.internal.SharedResourceHolder.Resource; +import java.util.concurrent.Executor; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -96,7 +97,7 @@ public final class OkHttpChannelBuilder extends return new OkHttpChannelBuilder(host, port); } - private ExecutorService transportExecutor; + private Executor transportExecutor; private final String host; private final int port; private String authorityHost; @@ -117,7 +118,7 @@ public final class OkHttpChannelBuilder extends *

The channel does not take ownership of the given executor. It is the caller' responsibility * to shutdown the executor when appropriate. */ - public OkHttpChannelBuilder transportExecutor(@Nullable ExecutorService transportExecutor) { + public OkHttpChannelBuilder transportExecutor(@Nullable Executor transportExecutor) { this.transportExecutor = transportExecutor; return this; } @@ -200,7 +201,7 @@ public final class OkHttpChannelBuilder extends private final String host; private final int port; private final String authorityHost; - private final ExecutorService executor; + private final Executor executor; private final boolean usingSharedExecutor; private final SSLSocketFactory socketFactory; private final ConnectionSpec connectionSpec; @@ -210,7 +211,7 @@ public final class OkHttpChannelBuilder extends private OkHttpTransportFactory(String host, int port, String authorityHost, - ExecutorService executor, + Executor executor, SSLSocketFactory socketFactory, ConnectionSpec connectionSpec, int maxMessageSize) { @@ -245,7 +246,7 @@ public final class OkHttpChannelBuilder extends @Override protected void deallocate() { if (usingSharedExecutor) { - SharedResourceHolder.release(SHARED_EXECUTOR, executor); + SharedResourceHolder.release(SHARED_EXECUTOR, (ExecutorService) executor); } } }