all: cleanup - errorprone, unused

This commit is contained in:
ZHANG Dapeng 2016-11-16 19:15:16 -08:00 committed by GitHub
parent e0e13c4897
commit e70f7b421c
9 changed files with 11 additions and 23 deletions

View File

@ -93,7 +93,7 @@ final class LoadServer {
new ByteBufOutputMarshaller(), new ByteBufOutputMarshaller(),
new ByteBufOutputMarshaller()); new ByteBufOutputMarshaller());
private static final Logger LOG = Logger.getLogger(LoadServer.class.getName()); private static final Logger log = Logger.getLogger(LoadServer.class.getName());
private final Server server; private final Server server;
private final BenchmarkServiceImpl benchmarkService; private final BenchmarkServiceImpl benchmarkService;
@ -105,7 +105,7 @@ final class LoadServer {
private long lastMarkCpuTime; private long lastMarkCpuTime;
LoadServer(Control.ServerConfig config) throws Exception { LoadServer(Control.ServerConfig config) throws Exception {
LOG.log(Level.INFO, "Server Config \n" + config.toString()); log.log(Level.INFO, "Server Config \n" + config.toString());
port = config.getPort() == 0 ? Utils.pickUnusedPort() : config.getPort(); port = config.getPort() == 0 ? Utils.pickUnusedPort() : config.getPort();
ServerBuilder<?> serverBuilder = ServerBuilder.forPort(port); ServerBuilder<?> serverBuilder = ServerBuilder.forPort(port);
int asyncThreads = config.getAsyncServerThreads() == 0 int asyncThreads = config.getAsyncServerThreads() == 0

View File

@ -110,7 +110,7 @@ public abstract class ManagedChannelProvider {
@VisibleForTesting @VisibleForTesting
static ManagedChannelProvider create(Class<?> rawClass) { static ManagedChannelProvider create(Class<?> rawClass) {
try { try {
return rawClass.asSubclass(ManagedChannelProvider.class).newInstance(); return rawClass.asSubclass(ManagedChannelProvider.class).getConstructor().newInstance();
} catch (Throwable t) { } catch (Throwable t) {
throw new ServiceConfigurationError( throw new ServiceConfigurationError(
"Provider " + rawClass.getName() + " could not be instantiated: " + t, t); "Provider " + rawClass.getName() + " could not be instantiated: " + t, t);

View File

@ -113,7 +113,7 @@ public abstract class NameResolverProvider extends NameResolver.Factory {
@VisibleForTesting @VisibleForTesting
static NameResolverProvider create(Class<?> rawClass) { static NameResolverProvider create(Class<?> rawClass) {
try { try {
return rawClass.asSubclass(NameResolverProvider.class).newInstance(); return rawClass.asSubclass(NameResolverProvider.class).getConstructor().newInstance();
} catch (Throwable t) { } catch (Throwable t) {
throw new ServiceConfigurationError( throw new ServiceConfigurationError(
"Provider " + rawClass.getName() + " could not be instantiated: " + t, t); "Provider " + rawClass.getName() + " could not be instantiated: " + t, t);

View File

@ -635,7 +635,7 @@ public final class Status {
public String parseAsciiString(byte[] value) { public String parseAsciiString(byte[] value) {
for (int i = 0; i < value.length; i++) { for (int i = 0; i < value.length; i++) {
byte b = value[i]; byte b = value[i];
if (b < ' ' || b >= '~' || b == '%' && i + 2 < value.length) { if (b < ' ' || b >= '~' || (b == '%' && i + 2 < value.length)) {
return parseAsciiStringSlow(value); return parseAsciiStringSlow(value);
} }
} }

View File

@ -215,7 +215,7 @@ public class CompositeReadableBuffer extends AbstractReadableBuffer {
* A simple read operation to perform on a single {@link ReadableBuffer}. All state management for * A simple read operation to perform on a single {@link ReadableBuffer}. All state management for
* the buffers is done by {@link CompositeReadableBuffer#execute(ReadOperation, int)}. * the buffers is done by {@link CompositeReadableBuffer#execute(ReadOperation, int)}.
*/ */
private abstract class ReadOperation { private abstract static class ReadOperation {
/** /**
* Only used by {@link CompositeReadableBuffer#readUnsignedByte()}. * Only used by {@link CompositeReadableBuffer#readUnsignedByte()}.
*/ */

View File

@ -368,7 +368,7 @@ public final class ServerImpl extends io.grpc.Server {
final StatsTraceContext statsTraceCtx = Preconditions.checkNotNull( final StatsTraceContext statsTraceCtx = Preconditions.checkNotNull(
stream.statsTraceContext(), "statsTraceCtx not present from stream"); stream.statsTraceContext(), "statsTraceCtx not present from stream");
final Context.CancellableContext context = createContext(stream, headers, statsTraceCtx); final Context.CancellableContext context = createContext(stream, headers);
final Executor wrappedExecutor; final Executor wrappedExecutor;
// This is a performance optimization that avoids the synchronization and queuing overhead // This is a performance optimization that avoids the synchronization and queuing overhead
// that comes with SerializingExecutor. // that comes with SerializingExecutor.
@ -421,7 +421,7 @@ public final class ServerImpl extends io.grpc.Server {
} }
private Context.CancellableContext createContext( private Context.CancellableContext createContext(
final ServerStream stream, Metadata headers, StatsTraceContext statsTraceCtx) { final ServerStream stream, Metadata headers) {
Long timeoutNanos = headers.get(TIMEOUT_KEY); Long timeoutNanos = headers.get(TIMEOUT_KEY);
// TODO(zhangkun83): attach the CensusContext from StatsTraceContext to baseContext // TODO(zhangkun83): attach the CensusContext from StatsTraceContext to baseContext

View File

@ -32,8 +32,8 @@
package io.grpc; package io.grpc;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import org.junit.Test; import org.junit.Test;
@ -79,8 +79,8 @@ public class ResolvedServerInfoTest {
Attributes.newBuilder().set(FOO, "bar").build()); Attributes.newBuilder().set(FOO, "bar").build());
// sanity checks that they're not same instances // sanity checks that they're not same instances
assertFalse(server1.getAddress() == server2.getAddress()); assertNotSame(server1.getAddress(), server2.getAddress());
assertFalse(server1.getAttributes() == server2.getAttributes()); assertNotSame(server1.getAttributes(), server2.getAttributes());
assertEquals(server1, server2); assertEquals(server1, server2);
assertEquals(server1.hashCode(), server2.hashCode()); // hash code must be consistent assertEquals(server1.hashCode(), server2.hashCode()); // hash code must be consistent

View File

@ -421,17 +421,6 @@ class NettyServerHandler extends AbstractNettyHandler {
return path.subSequence(1, path.length()).toString(); return path.subSequence(1, path.length()).toString();
} }
private static void checkHeader(int streamId,
Http2Headers headers,
CharSequence header,
CharSequence expectedValue) throws Http2Exception {
if (!expectedValue.equals(headers.get(header))) {
throw Http2Exception.streamError(streamId, Http2Error.REFUSED_STREAM,
"Header '%s'='%s', while '%s' is expected", header, headers.get(header), expectedValue);
}
}
/** /**
* Returns the server stream associated to the given HTTP/2 stream object. * Returns the server stream associated to the given HTTP/2 stream object.
*/ */

View File

@ -1150,7 +1150,6 @@ public abstract class AbstractTransportTest {
private static class MockServerTransportListener implements ServerTransportListener { private static class MockServerTransportListener implements ServerTransportListener {
public final ServerTransport transport; public final ServerTransport transport;
public final BlockingQueue<StreamCreation> streams = new LinkedBlockingQueue<StreamCreation>(); public final BlockingQueue<StreamCreation> streams = new LinkedBlockingQueue<StreamCreation>();
private final SettableFuture<?> ready = SettableFuture.create();
private final SettableFuture<?> terminated = SettableFuture.create(); private final SettableFuture<?> terminated = SettableFuture.create();
public MockServerTransportListener(ServerTransport transport) { public MockServerTransportListener(ServerTransport transport) {