aboutsummaryrefslogtreecommitdiff
path: root/stub
diff options
context:
space:
mode:
authorCarl Mastrangelo <notcarl@google.com>2017-07-14 13:38:04 -0700
committerGitHub <noreply@github.com>2017-07-14 13:38:04 -0700
commit193fd057a5ccc846355c4684b35cd67e4ca4c4d1 (patch)
tree412bd450b3ca498d8b713fd5b8850db2c6b18f83 /stub
parente6ad90e43e04ac3915d56827e0b898e7b3806033 (diff)
downloadgrpc-grpc-java-193fd057a5ccc846355c4684b35cd67e4ca4c4d1.tar.gz
stub: clean up client calls to avoid synthetic class
Diffstat (limited to 'stub')
-rw-r--r--stub/src/main/java/io/grpc/stub/ClientCalls.java40
1 files changed, 26 insertions, 14 deletions
diff --git a/stub/src/main/java/io/grpc/stub/ClientCalls.java b/stub/src/main/java/io/grpc/stub/ClientCalls.java
index 27d20db38..c4158cc6b 100644
--- a/stub/src/main/java/io/grpc/stub/ClientCalls.java
+++ b/stub/src/main/java/io/grpc/stub/ClientCalls.java
@@ -47,8 +47,6 @@ import javax.annotation.Nullable;
* that the runtime can vary behavior without requiring regeneration of the stub.
*/
public final class ClientCalls {
- private static final Logger log = Logger.getLogger(ClientCalls.class.getName());
-
// Prevent instantiation
private ClientCalls() {}
@@ -173,7 +171,7 @@ public final class ClientCalls {
}
/**
- * Returns the result of calling {@link Future#get()} interruptably on a task known not to throw a
+ * Returns the result of calling {@link Future#get()} interruptibly on a task known not to throw a
* checked exception.
*
* <p>If interrupted, the interrupt is restored before throwing an exception..
@@ -268,13 +266,14 @@ public final class ClientCalls {
}
}
- private static class CallToStreamObserverAdapter<T> extends ClientCallStreamObserver<T> {
+ private static final class CallToStreamObserverAdapter<T> extends ClientCallStreamObserver<T> {
private boolean frozen;
private final ClientCall<T, ?> call;
private Runnable onReadyHandler;
private boolean autoFlowControlEnabled = true;
- public CallToStreamObserverAdapter(ClientCall<T, ?> call) {
+ // Non private to avoid synthetic class
+ CallToStreamObserverAdapter(ClientCall<T, ?> call) {
this.call = call;
}
@@ -329,13 +328,14 @@ public final class ClientCalls {
}
}
- private static class StreamObserverToCallListenerAdapter<ReqT, RespT>
+ private static final class StreamObserverToCallListenerAdapter<ReqT, RespT>
extends ClientCall.Listener<RespT> {
private final StreamObserver<RespT> observer;
private final CallToStreamObserverAdapter<ReqT> adapter;
private final boolean streamingResponse;
private boolean firstResponseReceived;
+ // Non private to avoid synthetic class
StreamObserverToCallListenerAdapter(
StreamObserver<RespT> observer,
CallToStreamObserverAdapter<ReqT> adapter,
@@ -392,11 +392,12 @@ public final class ClientCalls {
/**
* Complete a GrpcFuture using {@link StreamObserver} events.
*/
- private static class UnaryStreamToFuture<RespT> extends ClientCall.Listener<RespT> {
+ private static final class UnaryStreamToFuture<RespT> extends ClientCall.Listener<RespT> {
private final GrpcFuture<RespT> responseFuture;
private RespT value;
- public UnaryStreamToFuture(GrpcFuture<RespT> responseFuture) {
+ // Non private to avoid synthetic class
+ UnaryStreamToFuture(GrpcFuture<RespT> responseFuture) {
this.responseFuture = responseFuture;
}
@@ -429,9 +430,10 @@ public final class ClientCalls {
}
}
- private static class GrpcFuture<RespT> extends AbstractFuture<RespT> {
+ private static final class GrpcFuture<RespT> extends AbstractFuture<RespT> {
private final ClientCall<?, RespT> call;
+ // Non private to avoid synthetic class
GrpcFuture(ClientCall<?, RespT> call) {
this.call = call;
}
@@ -460,7 +462,7 @@ public final class ClientCalls {
* separate thread from {@code Iterator} calls.
*/
// TODO(ejona86): determine how to allow ClientCall.cancel() in case of application error.
- private static class BlockingResponseStream<T> implements Iterator<T> {
+ private static final class BlockingResponseStream<T> implements Iterator<T> {
// Due to flow control, only needs to hold up to 2 items: 1 for value, 1 for close.
private final BlockingQueue<Object> buffer = new ArrayBlockingQueue<Object>(2);
private final ClientCall.Listener<T> listener = new QueuingListener();
@@ -470,11 +472,13 @@ public final class ClientCalls {
// Only accessed when iterating.
private Object last;
- private BlockingResponseStream(ClientCall<?, T> call) {
+ // Non private to avoid synthetic class
+ BlockingResponseStream(ClientCall<?, T> call) {
this(call, null);
}
- private BlockingResponseStream(ClientCall<?, T> call, ThreadlessExecutor threadless) {
+ // Non private to avoid synthetic class
+ BlockingResponseStream(ClientCall<?, T> call, ThreadlessExecutor threadless) {
this.call = call;
this.threadless = threadless;
}
@@ -536,7 +540,10 @@ public final class ClientCalls {
throw new UnsupportedOperationException();
}
- private class QueuingListener extends ClientCall.Listener<T> {
+ private final class QueuingListener extends ClientCall.Listener<T> {
+ // Non private to avoid synthetic class
+ QueuingListener() {}
+
private boolean done = false;
@Override
@@ -562,9 +569,14 @@ public final class ClientCalls {
}
}
- private static class ThreadlessExecutor implements Executor {
+ private static final class ThreadlessExecutor implements Executor {
+ private static final Logger log = Logger.getLogger(ThreadlessExecutor.class.getName());
+
private final BlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>();
+ // Non private to avoid synthetic class
+ ThreadlessExecutor() {}
+
/**
* Waits until there is a Runnable, then executes it and all queued Runnables after it.
*/