mirror of https://github.com/grpc/grpc-java.git
core: Fix unused variables
I did not fix the unused statsTraceCtx in AbstractClientStream2.GetFramer. Instead, I opened https://github.com/grpc/grpc-java/issues/2896
This commit is contained in:
parent
fd30b68d3c
commit
c8dff0d974
|
|
@ -187,8 +187,7 @@ public abstract class AbstractServerImplBuilder<T extends AbstractServerImplBuil
|
||||||
firstNonNull(fallbackRegistry, EMPTY_FALLBACK_REGISTRY), transportServer,
|
firstNonNull(fallbackRegistry, EMPTY_FALLBACK_REGISTRY), transportServer,
|
||||||
Context.ROOT, firstNonNull(decompressorRegistry, DecompressorRegistry.getDefaultInstance()),
|
Context.ROOT, firstNonNull(decompressorRegistry, DecompressorRegistry.getDefaultInstance()),
|
||||||
firstNonNull(compressorRegistry, CompressorRegistry.getDefaultInstance()),
|
firstNonNull(compressorRegistry, CompressorRegistry.getDefaultInstance()),
|
||||||
transportFilters,
|
transportFilters);
|
||||||
GrpcUtil.STOPWATCH_SUPPLIER);
|
|
||||||
for (InternalNotifyOnServerBuild notifyTarget : notifyOnBuildList) {
|
for (InternalNotifyOnServerBuild notifyTarget : notifyOnBuildList) {
|
||||||
notifyTarget.notifyOnBuild(server);
|
notifyTarget.notifyOnBuild(server);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,7 @@ final class CensusStreamTracerModule {
|
||||||
* Returns the server tracer factory.
|
* Returns the server tracer factory.
|
||||||
*/
|
*/
|
||||||
ServerStreamTracer.Factory getServerTracerFactory() {
|
ServerStreamTracer.Factory getServerTracerFactory() {
|
||||||
return new ServerTracerFactory();
|
return serverTracerFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -659,7 +659,7 @@ public final class ManagedChannelImpl extends ManagedChannel implements WithLogI
|
||||||
"scheduledExecutor is already cleared. Looks like you are calling this method after "
|
"scheduledExecutor is already cleared. Looks like you are calling this method after "
|
||||||
+ "you've already shut down");
|
+ "you've already shut down");
|
||||||
final OobChannel oobChannel = new OobChannel(
|
final OobChannel oobChannel = new OobChannel(
|
||||||
authority, oobExecutorPool, scheduledExecutorCopy, stopwatchSupplier, channelExecutor);
|
authority, oobExecutorPool, scheduledExecutorCopy, channelExecutor);
|
||||||
final InternalSubchannel internalSubchannel = new InternalSubchannel(
|
final InternalSubchannel internalSubchannel = new InternalSubchannel(
|
||||||
addressGroup, authority, userAgent, backoffPolicyProvider, transportFactory,
|
addressGroup, authority, userAgent, backoffPolicyProvider, transportFactory,
|
||||||
scheduledExecutorCopy, stopwatchSupplier, channelExecutor,
|
scheduledExecutorCopy, stopwatchSupplier, channelExecutor,
|
||||||
|
|
|
||||||
|
|
@ -178,7 +178,7 @@ public class MessageFramer implements Framer {
|
||||||
return written;
|
return written;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int writeCompressed(InputStream message, int messageLength) throws IOException {
|
private int writeCompressed(InputStream message, int unusedMessageLength) throws IOException {
|
||||||
BufferChainOutputStream bufferChain = new BufferChainOutputStream();
|
BufferChainOutputStream bufferChain = new BufferChainOutputStream();
|
||||||
|
|
||||||
OutputStream compressingStream = compressor.compress(bufferChain);
|
OutputStream compressingStream = compressor.compress(bufferChain);
|
||||||
|
|
|
||||||
|
|
@ -33,8 +33,6 @@ package io.grpc.internal;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.google.common.base.Stopwatch;
|
|
||||||
import com.google.common.base.Supplier;
|
|
||||||
import io.grpc.Attributes;
|
import io.grpc.Attributes;
|
||||||
import io.grpc.CallOptions;
|
import io.grpc.CallOptions;
|
||||||
import io.grpc.ClientCall;
|
import io.grpc.ClientCall;
|
||||||
|
|
@ -73,7 +71,6 @@ final class OobChannel extends ManagedChannel implements WithLogId {
|
||||||
private final ObjectPool<? extends Executor> executorPool;
|
private final ObjectPool<? extends Executor> executorPool;
|
||||||
private final Executor executor;
|
private final Executor executor;
|
||||||
private final ScheduledExecutorService deadlineCancellationExecutor;
|
private final ScheduledExecutorService deadlineCancellationExecutor;
|
||||||
private final Supplier<Stopwatch> stopwatchSupplier;
|
|
||||||
private final CountDownLatch terminatedLatch = new CountDownLatch(1);
|
private final CountDownLatch terminatedLatch = new CountDownLatch(1);
|
||||||
private volatile boolean shutdown;
|
private volatile boolean shutdown;
|
||||||
|
|
||||||
|
|
@ -89,14 +86,12 @@ final class OobChannel extends ManagedChannel implements WithLogId {
|
||||||
|
|
||||||
OobChannel(
|
OobChannel(
|
||||||
String authority, ObjectPool<? extends Executor> executorPool,
|
String authority, ObjectPool<? extends Executor> executorPool,
|
||||||
ScheduledExecutorService deadlineCancellationExecutor, Supplier<Stopwatch> stopwatchSupplier,
|
ScheduledExecutorService deadlineCancellationExecutor, ChannelExecutor channelExecutor) {
|
||||||
ChannelExecutor channelExecutor) {
|
|
||||||
this.authority = checkNotNull(authority, "authority");
|
this.authority = checkNotNull(authority, "authority");
|
||||||
this.executorPool = checkNotNull(executorPool, "executorPool");
|
this.executorPool = checkNotNull(executorPool, "executorPool");
|
||||||
this.executor = checkNotNull(executorPool.getObject(), "executor");
|
this.executor = checkNotNull(executorPool.getObject(), "executor");
|
||||||
this.deadlineCancellationExecutor = checkNotNull(
|
this.deadlineCancellationExecutor = checkNotNull(
|
||||||
deadlineCancellationExecutor, "deadlineCancellationExecutor");
|
deadlineCancellationExecutor, "deadlineCancellationExecutor");
|
||||||
this.stopwatchSupplier = checkNotNull(stopwatchSupplier, "stopwatchSupplier");
|
|
||||||
this.delayedTransport = new DelayedClientTransport(executor, channelExecutor);
|
this.delayedTransport = new DelayedClientTransport(executor, channelExecutor);
|
||||||
this.delayedTransport.start(new ManagedClientTransport.Listener() {
|
this.delayedTransport.start(new ManagedClientTransport.Listener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -40,8 +40,6 @@ import static java.util.concurrent.TimeUnit.NANOSECONDS;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.common.base.Stopwatch;
|
|
||||||
import com.google.common.base.Supplier;
|
|
||||||
import io.grpc.Attributes;
|
import io.grpc.Attributes;
|
||||||
import io.grpc.CompressorRegistry;
|
import io.grpc.CompressorRegistry;
|
||||||
import io.grpc.Context;
|
import io.grpc.Context;
|
||||||
|
|
@ -110,7 +108,6 @@ public final class ServerImpl extends io.grpc.Server implements WithLogId {
|
||||||
|
|
||||||
private final DecompressorRegistry decompressorRegistry;
|
private final DecompressorRegistry decompressorRegistry;
|
||||||
private final CompressorRegistry compressorRegistry;
|
private final CompressorRegistry compressorRegistry;
|
||||||
private final Supplier<Stopwatch> stopwatchSupplier;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a server.
|
* Construct a server.
|
||||||
|
|
@ -125,8 +122,7 @@ public final class ServerImpl extends io.grpc.Server implements WithLogId {
|
||||||
InternalHandlerRegistry registry, HandlerRegistry fallbackRegistry,
|
InternalHandlerRegistry registry, HandlerRegistry fallbackRegistry,
|
||||||
InternalServer transportServer, Context rootContext,
|
InternalServer transportServer, Context rootContext,
|
||||||
DecompressorRegistry decompressorRegistry, CompressorRegistry compressorRegistry,
|
DecompressorRegistry decompressorRegistry, CompressorRegistry compressorRegistry,
|
||||||
List<ServerTransportFilter> transportFilters,
|
List<ServerTransportFilter> transportFilters) {
|
||||||
Supplier<Stopwatch> stopwatchSupplier) {
|
|
||||||
this.executorPool = Preconditions.checkNotNull(executorPool, "executorPool");
|
this.executorPool = Preconditions.checkNotNull(executorPool, "executorPool");
|
||||||
this.timeoutServicePool = Preconditions.checkNotNull(timeoutServicePool, "timeoutServicePool");
|
this.timeoutServicePool = Preconditions.checkNotNull(timeoutServicePool, "timeoutServicePool");
|
||||||
this.registry = Preconditions.checkNotNull(registry, "registry");
|
this.registry = Preconditions.checkNotNull(registry, "registry");
|
||||||
|
|
@ -139,7 +135,6 @@ public final class ServerImpl extends io.grpc.Server implements WithLogId {
|
||||||
this.compressorRegistry = compressorRegistry;
|
this.compressorRegistry = compressorRegistry;
|
||||||
this.transportFilters = Collections.unmodifiableList(
|
this.transportFilters = Collections.unmodifiableList(
|
||||||
new ArrayList<ServerTransportFilter>(transportFilters));
|
new ArrayList<ServerTransportFilter>(transportFilters));
|
||||||
this.stopwatchSupplier = Preconditions.checkNotNull(stopwatchSupplier, "stopwatchSupplier");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -423,7 +418,7 @@ public final class ServerImpl extends io.grpc.Server implements WithLogId {
|
||||||
context.cancel(null);
|
context.cancel(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
listener = startCall(stream, methodName, method, headers, context, statsTraceCtx);
|
listener = startCall(stream, methodName, method, headers, context);
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
stream.close(Status.fromThrowable(e), new Metadata());
|
stream.close(Status.fromThrowable(e), new Metadata());
|
||||||
context.cancel(null);
|
context.cancel(null);
|
||||||
|
|
@ -469,7 +464,7 @@ public final class ServerImpl extends io.grpc.Server implements WithLogId {
|
||||||
/** Never returns {@code null}. */
|
/** Never returns {@code null}. */
|
||||||
private <ReqT, RespT> ServerStreamListener startCall(ServerStream stream, String fullMethodName,
|
private <ReqT, RespT> ServerStreamListener startCall(ServerStream stream, String fullMethodName,
|
||||||
ServerMethodDefinition<ReqT, RespT> methodDef, Metadata headers,
|
ServerMethodDefinition<ReqT, RespT> methodDef, Metadata headers,
|
||||||
Context.CancellableContext context, StatsTraceContext statsTraceCtx) {
|
Context.CancellableContext context) {
|
||||||
// TODO(ejona86): should we update fullMethodName to have the canonical path of the method?
|
// TODO(ejona86): should we update fullMethodName to have the canonical path of the method?
|
||||||
ServerCallImpl<ReqT, RespT> call = new ServerCallImpl<ReqT, RespT>(
|
ServerCallImpl<ReqT, RespT> call = new ServerCallImpl<ReqT, RespT>(
|
||||||
stream, methodDef.getMethodDescriptor(), headers, context,
|
stream, methodDef.getMethodDescriptor(), headers, context,
|
||||||
|
|
|
||||||
|
|
@ -42,12 +42,12 @@ import org.junit.runners.JUnit4;
|
||||||
/** Unit tests for {@link InProcessTransport}. */
|
/** Unit tests for {@link InProcessTransport}. */
|
||||||
@RunWith(JUnit4.class)
|
@RunWith(JUnit4.class)
|
||||||
public class InProcessTransportTest extends AbstractTransportTest {
|
public class InProcessTransportTest extends AbstractTransportTest {
|
||||||
private static final String transportName = "perfect-for-testing";
|
private static final String TRANSPORT_NAME = "perfect-for-testing";
|
||||||
private static final String authority = "a-testing-authority";
|
private static final String AUTHORITY = "a-testing-authority";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected InternalServer newServer(List<ServerStreamTracer.Factory> streamTracerFactories) {
|
protected InternalServer newServer(List<ServerStreamTracer.Factory> streamTracerFactories) {
|
||||||
return new InProcessServer(transportName);
|
return new InProcessServer(TRANSPORT_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -58,12 +58,12 @@ public class InProcessTransportTest extends AbstractTransportTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String testAuthority(InternalServer server) {
|
protected String testAuthority(InternalServer server) {
|
||||||
return authority;
|
return AUTHORITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ManagedClientTransport newClientTransport(InternalServer server) {
|
protected ManagedClientTransport newClientTransport(InternalServer server) {
|
||||||
return new InProcessTransport(transportName, testAuthority(server));
|
return new InProcessTransport(TRANSPORT_NAME, testAuthority(server));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -266,7 +266,7 @@ public class CensusStreamTracerModuleTest {
|
||||||
ClientCallTracer callTracer = census.newClientCallTracer(clientCtx, methodName);
|
ClientCallTracer callTracer = census.newClientCallTracer(clientCtx, methodName);
|
||||||
Metadata headers = new Metadata();
|
Metadata headers = new Metadata();
|
||||||
// This propagates clientCtx to headers
|
// This propagates clientCtx to headers
|
||||||
ClientStreamTracer clientTracer = callTracer.newClientStreamTracer(headers);
|
callTracer.newClientStreamTracer(headers);
|
||||||
|
|
||||||
ServerStreamTracer serverTracer =
|
ServerStreamTracer serverTracer =
|
||||||
census.getServerTracerFactory().newServerStreamTracer(methodName, headers);
|
census.getServerTracerFactory().newServerStreamTracer(methodName, headers);
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,6 @@ import static org.mockito.Mockito.verifyZeroInteractions;
|
||||||
|
|
||||||
import io.grpc.Codec;
|
import io.grpc.Codec;
|
||||||
import io.grpc.StreamTracer;
|
import io.grpc.StreamTracer;
|
||||||
import io.grpc.internal.testing.StatsTestUtils.FakeStatsContextFactory;
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
@ -77,14 +76,12 @@ public class MessageFramerTest {
|
||||||
private ArgumentCaptor<Long> uncompressedSizeCaptor;
|
private ArgumentCaptor<Long> uncompressedSizeCaptor;
|
||||||
private BytesWritableBufferAllocator allocator =
|
private BytesWritableBufferAllocator allocator =
|
||||||
new BytesWritableBufferAllocator(1000, 1000);
|
new BytesWritableBufferAllocator(1000, 1000);
|
||||||
private FakeStatsContextFactory statsCtxFactory;
|
|
||||||
private StatsTraceContext statsTraceCtx;
|
private StatsTraceContext statsTraceCtx;
|
||||||
|
|
||||||
/** Set up for test. */
|
/** Set up for test. */
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
statsCtxFactory = new FakeStatsContextFactory();
|
|
||||||
// MessageDeframerTest tests with a client-side StatsTraceContext, so here we test with a
|
// MessageDeframerTest tests with a client-side StatsTraceContext, so here we test with a
|
||||||
// server-side StatsTraceContext.
|
// server-side StatsTraceContext.
|
||||||
statsTraceCtx = new StatsTraceContext(new StreamTracer[]{tracer});
|
statsTraceCtx = new StatsTraceContext(new StreamTracer[]{tracer});
|
||||||
|
|
|
||||||
|
|
@ -1033,8 +1033,7 @@ public class ServerImplTest {
|
||||||
private void createServer(List<ServerTransportFilter> filters) {
|
private void createServer(List<ServerTransportFilter> filters) {
|
||||||
assertNull(server);
|
assertNull(server);
|
||||||
server = new ServerImpl(executorPool, timerPool, registry, fallbackRegistry,
|
server = new ServerImpl(executorPool, timerPool, registry, fallbackRegistry,
|
||||||
transportServer, SERVER_CONTEXT, decompressorRegistry, compressorRegistry, filters,
|
transportServer, SERVER_CONTEXT, decompressorRegistry, compressorRegistry, filters);
|
||||||
GrpcUtil.STOPWATCH_SUPPLIER);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyExecutorsAcquired() {
|
private void verifyExecutorsAcquired() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue