Use Executor in stable builder APIs instead of ExecutorService
diff --git a/core/src/main/java/io/grpc/ManagedChannelBuilder.java b/core/src/main/java/io/grpc/ManagedChannelBuilder.java
index 3fd56c1..dda4f8f 100644
--- a/core/src/main/java/io/grpc/ManagedChannelBuilder.java
+++ b/core/src/main/java/io/grpc/ManagedChannelBuilder.java
@@ -32,7 +32,7 @@
package io.grpc;
import java.util.List;
-import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executor;
/**
* A builder for {@link ManagedChannel} instances.
@@ -50,7 +50,7 @@
* <p>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 a8e2902..60a6d61 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 @@
* <p>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 dd81e13..5097c9f 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 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 @@
<T extends AbstractManagedChannelImplBuilder<T>> extends ManagedChannelBuilder<T> {
@Nullable
- private ExecutorService executor;
+ private Executor executor;
private final List<ClientInterceptor> interceptors = new ArrayList<ClientInterceptor>();
@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 d224912..7fb2a7f 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.ServerBuilder;
import io.grpc.ServerServiceDefinition;
-import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executor;
import javax.annotation.Nullable;
@@ -54,7 +54,7 @@
private final HandlerRegistry registry;
@Nullable
- private ExecutorService executor;
+ private Executor executor;
/**
* Constructs using a given handler registry.
@@ -71,7 +71,7 @@
}
@Override
- public final T executor(@Nullable ExecutorService executor) {
+ public final T executor(@Nullable Executor executor) {
this.executor = executor;
return thisT();
}
diff --git a/core/src/main/java/io/grpc/internal/ManagedChannelImpl.java b/core/src/main/java/io/grpc/internal/ManagedChannelImpl.java
index d2f5669..9bbc9db 100644
--- a/core/src/main/java/io/grpc/internal/ManagedChannelImpl.java
+++ b/core/src/main/java/io/grpc/internal/ManagedChannelImpl.java
@@ -67,7 +67,7 @@
private static final Logger log = Logger.getLogger(ManagedChannelImpl.class.getName());
private final ClientTransportFactory transportFactory;
- private final ExecutorService executor;
+ private final Executor executor;
private final boolean usingSharedExecutor;
private final String userAgent;
private final Object lock = new Object();
@@ -114,7 +114,7 @@
}
};
- ManagedChannelImpl(ClientTransportFactory transportFactory, @Nullable ExecutorService executor,
+ ManagedChannelImpl(ClientTransportFactory transportFactory, @Nullable Executor executor,
@Nullable String userAgent, List<ClientInterceptor> interceptors) {
this.transportFactory = transportFactory;
this.userAgent = userAgent;
@@ -387,7 +387,7 @@
*/
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();