mirror of https://github.com/grpc/grpc-java.git
all: fix lint
This commit is contained in:
parent
d35fbd7eee
commit
a2cda8d15d
|
|
@ -188,11 +188,6 @@ public class ClientAuthInterceptorTest {
|
||||||
private static final class ClientCallRecorder extends ClientCall<String, Integer> {
|
private static final class ClientCallRecorder extends ClientCall<String, Integer> {
|
||||||
private ClientCall.Listener<Integer> responseListener;
|
private ClientCall.Listener<Integer> responseListener;
|
||||||
private Metadata headers;
|
private Metadata headers;
|
||||||
private int numMessages;
|
|
||||||
private String cancelMessage;
|
|
||||||
private Throwable cancelCause;
|
|
||||||
private boolean halfClosed;
|
|
||||||
private String sentMessage;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(ClientCall.Listener<Integer> responseListener, Metadata headers) {
|
public void start(ClientCall.Listener<Integer> responseListener, Metadata headers) {
|
||||||
|
|
@ -202,23 +197,18 @@ public class ClientAuthInterceptorTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void request(int numMessages) {
|
public void request(int numMessages) {
|
||||||
this.numMessages = numMessages;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cancel(String message, Throwable cause) {
|
public void cancel(String message, Throwable cause) {
|
||||||
this.cancelMessage = message;
|
|
||||||
this.cancelCause = cause;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void halfClose() {
|
public void halfClose() {
|
||||||
halfClosed = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(String message) {
|
public void sendMessage(String message) {
|
||||||
sentMessage = message;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,6 @@ import io.grpc.Status;
|
||||||
import io.grpc.internal.ServiceConfigUtil.LbConfig;
|
import io.grpc.internal.ServiceConfigUtil.LbConfig;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
@ -66,23 +65,6 @@ public final class AutoConfiguredLoadBalancerFactory extends LoadBalancer.Factor
|
||||||
return new AutoConfiguredLoadBalancer(helper);
|
return new AutoConfiguredLoadBalancer(helper);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class AutoConfiguredLoadBalancerServiceConfig {
|
|
||||||
@Nullable
|
|
||||||
private final Map<String, ?> loadBalancingConfigs;
|
|
||||||
|
|
||||||
AutoConfiguredLoadBalancerServiceConfig(@Nullable Map<String, ?> loadBalancingConfigs) {
|
|
||||||
if (loadBalancingConfigs != null) {
|
|
||||||
Map<String, Object> lbMapping = new LinkedHashMap<>();
|
|
||||||
for (Map.Entry<String, ?> entry : loadBalancingConfigs.entrySet()) {
|
|
||||||
lbMapping.put(entry.getKey(), entry.getValue());
|
|
||||||
}
|
|
||||||
this.loadBalancingConfigs = Collections.unmodifiableMap(lbMapping);
|
|
||||||
} else {
|
|
||||||
this.loadBalancingConfigs = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final class NoopLoadBalancer extends LoadBalancer {
|
private static final class NoopLoadBalancer extends LoadBalancer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ final class ManagedChannelServiceConfig {
|
||||||
|
|
||||||
private final Map<String, MethodInfo> serviceMethodMap;
|
private final Map<String, MethodInfo> serviceMethodMap;
|
||||||
private final Map<String, MethodInfo> serviceMap;
|
private final Map<String, MethodInfo> serviceMap;
|
||||||
|
// TODO(notcarl/zdapeng): use retryThrottling here
|
||||||
@Nullable
|
@Nullable
|
||||||
private final Throttle retryThrottling;
|
private final Throttle retryThrottling;
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|
|
||||||
|
|
@ -430,8 +430,6 @@ public class ClientInterceptorsTest {
|
||||||
private List<Integer> requests = new ArrayList<>();
|
private List<Integer> requests = new ArrayList<>();
|
||||||
private List<String> messages = new ArrayList<>();
|
private List<String> messages = new ArrayList<>();
|
||||||
private boolean halfClosed;
|
private boolean halfClosed;
|
||||||
private Throwable cancelCause;
|
|
||||||
private String cancelMessage;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(ClientCall.Listener<Integer> listener, Metadata headers) {
|
public void start(ClientCall.Listener<Integer> listener, Metadata headers) {
|
||||||
|
|
@ -451,8 +449,6 @@ public class ClientInterceptorsTest {
|
||||||
@Override
|
@Override
|
||||||
public void cancel(String message, Throwable cause) {
|
public void cancel(String message, Throwable cause) {
|
||||||
checkNotDone();
|
checkNotDone();
|
||||||
this.cancelMessage = message;
|
|
||||||
this.cancelCause = cause;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.ExpectedException;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.JUnit4;
|
import org.junit.runners.JUnit4;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
|
|
@ -54,6 +55,9 @@ public class ServerInterceptorsTest {
|
||||||
@Rule
|
@Rule
|
||||||
public final MockitoRule mocks = MockitoJUnit.rule();
|
public final MockitoRule mocks = MockitoJUnit.rule();
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public final ExpectedException thrown = ExpectedException.none();
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private Marshaller<String> requestMarshaller;
|
private Marshaller<String> requestMarshaller;
|
||||||
|
|
||||||
|
|
@ -100,20 +104,25 @@ public class ServerInterceptorsTest {
|
||||||
verifyZeroInteractions(listener);
|
verifyZeroInteractions(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = NullPointerException.class)
|
@Test
|
||||||
public void npeForNullServiceDefinition() {
|
public void npeForNullServiceDefinition() {
|
||||||
ServerServiceDefinition serviceDef = null;
|
ServerServiceDefinition serviceDef = null;
|
||||||
ServerInterceptors.intercept(serviceDef, Arrays.<ServerInterceptor>asList());
|
List<ServerInterceptor> interceptors = Arrays.asList();
|
||||||
|
thrown.expect(NullPointerException.class);
|
||||||
|
ServerInterceptors.intercept(serviceDef, interceptors);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = NullPointerException.class)
|
@Test
|
||||||
public void npeForNullInterceptorList() {
|
public void npeForNullInterceptorList() {
|
||||||
|
thrown.expect(NullPointerException.class);
|
||||||
ServerInterceptors.intercept(serviceDefinition, (List<ServerInterceptor>) null);
|
ServerInterceptors.intercept(serviceDefinition, (List<ServerInterceptor>) null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = NullPointerException.class)
|
@Test
|
||||||
public void npeForNullInterceptor() {
|
public void npeForNullInterceptor() {
|
||||||
ServerInterceptors.intercept(serviceDefinition, Arrays.asList((ServerInterceptor) null));
|
List<ServerInterceptor> interceptors = Arrays.asList((ServerInterceptor) null);
|
||||||
|
thrown.expect(NullPointerException.class);
|
||||||
|
ServerInterceptors.intercept(serviceDefinition, interceptors);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -312,7 +312,7 @@ public class DnsNameResolverTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void resolveAll_failsOnEmptyResult() throws Exception {
|
public void resolveAll_failsOnEmptyResult() {
|
||||||
DnsNameResolver nr = newResolver("dns:///addr.fake:1234", 443);
|
DnsNameResolver nr = newResolver("dns:///addr.fake:1234", 443);
|
||||||
nr.setAddressResolver(new AddressResolver() {
|
nr.setAddressResolver(new AddressResolver() {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -895,24 +895,23 @@ public class DnsNameResolverTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseTxtResults_badTypeFails() throws Exception {
|
public void parseTxtResults_badTypeFails() throws Exception {
|
||||||
thrown.expect(ClassCastException.class);
|
|
||||||
thrown.expectMessage("wrong type");
|
|
||||||
List<String> txtRecords = new ArrayList<>();
|
List<String> txtRecords = new ArrayList<>();
|
||||||
txtRecords.add("some_record");
|
txtRecords.add("some_record");
|
||||||
txtRecords.add("grpc_config={}");
|
txtRecords.add("grpc_config={}");
|
||||||
|
|
||||||
|
thrown.expect(ClassCastException.class);
|
||||||
|
thrown.expectMessage("wrong type");
|
||||||
DnsNameResolver.parseTxtResults(txtRecords);
|
DnsNameResolver.parseTxtResults(txtRecords);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseTxtResults_badInnerTypeFails() throws Exception {
|
public void parseTxtResults_badInnerTypeFails() throws Exception {
|
||||||
thrown.expect(ClassCastException.class);
|
|
||||||
thrown.expectMessage("not object");
|
|
||||||
|
|
||||||
List<String> txtRecords = new ArrayList<>();
|
List<String> txtRecords = new ArrayList<>();
|
||||||
txtRecords.add("some_record");
|
txtRecords.add("some_record");
|
||||||
txtRecords.add("grpc_config=[\"bogus\"]");
|
txtRecords.add("grpc_config=[\"bogus\"]");
|
||||||
|
|
||||||
|
thrown.expect(ClassCastException.class);
|
||||||
|
thrown.expectMessage("not object");
|
||||||
DnsNameResolver.parseTxtResults(txtRecords);
|
DnsNameResolver.parseTxtResults(txtRecords);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,10 +60,6 @@ public class MessageFramerTest {
|
||||||
|
|
||||||
@Captor
|
@Captor
|
||||||
private ArgumentCaptor<ByteWritableBuffer> frameCaptor;
|
private ArgumentCaptor<ByteWritableBuffer> frameCaptor;
|
||||||
@Captor
|
|
||||||
private ArgumentCaptor<Long> wireSizeCaptor;
|
|
||||||
@Captor
|
|
||||||
private ArgumentCaptor<Long> uncompressedSizeCaptor;
|
|
||||||
private BytesWritableBufferAllocator allocator =
|
private BytesWritableBufferAllocator allocator =
|
||||||
new BytesWritableBufferAllocator(1000, 1000);
|
new BytesWritableBufferAllocator(1000, 1000);
|
||||||
private StatsTraceContext statsTraceCtx;
|
private StatsTraceContext statsTraceCtx;
|
||||||
|
|
@ -170,7 +166,7 @@ public class MessageFramerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void emptyPayloadYieldsFrame() throws Exception {
|
public void emptyPayloadYieldsFrame() {
|
||||||
writeKnownLength(framer, new byte[0]);
|
writeKnownLength(framer, new byte[0]);
|
||||||
framer.flush();
|
framer.flush();
|
||||||
verify(sink).deliverFrame(toWriteBuffer(new byte[] {0, 0, 0, 0, 0}), false, true, 1);
|
verify(sink).deliverFrame(toWriteBuffer(new byte[] {0, 0, 0, 0, 0}), false, true, 1);
|
||||||
|
|
@ -179,7 +175,7 @@ public class MessageFramerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void emptyUnknownLengthPayloadYieldsFrame() throws Exception {
|
public void emptyUnknownLengthPayloadYieldsFrame() {
|
||||||
writeUnknownLength(framer, new byte[0]);
|
writeUnknownLength(framer, new byte[0]);
|
||||||
verifyZeroInteractions(sink);
|
verifyZeroInteractions(sink);
|
||||||
framer.flush();
|
framer.flush();
|
||||||
|
|
@ -201,7 +197,7 @@ public class MessageFramerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void largerFrameSize() throws Exception {
|
public void largerFrameSize() {
|
||||||
allocator = new BytesWritableBufferAllocator(0, 10000);
|
allocator = new BytesWritableBufferAllocator(0, 10000);
|
||||||
framer = new MessageFramer(sink, allocator, statsTraceCtx);
|
framer = new MessageFramer(sink, allocator, statsTraceCtx);
|
||||||
writeKnownLength(framer, new byte[1000]);
|
writeKnownLength(framer, new byte[1000]);
|
||||||
|
|
@ -221,7 +217,7 @@ public class MessageFramerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void largerFrameSizeUnknownLength() throws Exception {
|
public void largerFrameSizeUnknownLength() {
|
||||||
// Force payload to be split into two chunks
|
// Force payload to be split into two chunks
|
||||||
allocator = new BytesWritableBufferAllocator(500, 500);
|
allocator = new BytesWritableBufferAllocator(500, 500);
|
||||||
framer = new MessageFramer(sink, allocator, statsTraceCtx);
|
framer = new MessageFramer(sink, allocator, statsTraceCtx);
|
||||||
|
|
@ -249,7 +245,7 @@ public class MessageFramerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void compressed() throws Exception {
|
public void compressed() {
|
||||||
allocator = new BytesWritableBufferAllocator(100, Integer.MAX_VALUE);
|
allocator = new BytesWritableBufferAllocator(100, Integer.MAX_VALUE);
|
||||||
// setMessageCompression should default to true
|
// setMessageCompression should default to true
|
||||||
framer = new MessageFramer(sink, allocator, statsTraceCtx)
|
framer = new MessageFramer(sink, allocator, statsTraceCtx)
|
||||||
|
|
@ -276,7 +272,7 @@ public class MessageFramerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void dontCompressIfNoEncoding() throws Exception {
|
public void dontCompressIfNoEncoding() {
|
||||||
allocator = new BytesWritableBufferAllocator(100, Integer.MAX_VALUE);
|
allocator = new BytesWritableBufferAllocator(100, Integer.MAX_VALUE);
|
||||||
framer = new MessageFramer(sink, allocator, statsTraceCtx)
|
framer = new MessageFramer(sink, allocator, statsTraceCtx)
|
||||||
.setMessageCompression(true);
|
.setMessageCompression(true);
|
||||||
|
|
@ -301,7 +297,7 @@ public class MessageFramerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void dontCompressIfNotRequested() throws Exception {
|
public void dontCompressIfNotRequested() {
|
||||||
allocator = new BytesWritableBufferAllocator(100, Integer.MAX_VALUE);
|
allocator = new BytesWritableBufferAllocator(100, Integer.MAX_VALUE);
|
||||||
framer = new MessageFramer(sink, allocator, statsTraceCtx)
|
framer = new MessageFramer(sink, allocator, statsTraceCtx)
|
||||||
.setCompressor(new Codec.Gzip())
|
.setCompressor(new Codec.Gzip())
|
||||||
|
|
@ -327,7 +323,7 @@ public class MessageFramerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void closeIsRentrantSafe() throws Exception {
|
public void closeIsRentrantSafe() {
|
||||||
MessageFramer.Sink reentrant = new MessageFramer.Sink() {
|
MessageFramer.Sink reentrant = new MessageFramer.Sink() {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@ public class SharedResourceHolderTest {
|
||||||
ResourceInstance foo3 = holder.getInternal(SHARED_FOO);
|
ResourceInstance foo3 = holder.getInternal(SHARED_FOO);
|
||||||
assertNotSame(sharedFoo, foo3);
|
assertNotSame(sharedFoo, foo3);
|
||||||
|
|
||||||
bar1 = holder.releaseInternal(SHARED_BAR, bar1);
|
holder.releaseInternal(SHARED_BAR, bar1);
|
||||||
|
|
||||||
// bar refcount has reached 0, a destroying task is scheduled
|
// bar refcount has reached 0, a destroying task is scheduled
|
||||||
assertEquals(1, scheduledDestroyTasks.size());
|
assertEquals(1, scheduledDestroyTasks.size());
|
||||||
|
|
@ -122,7 +122,7 @@ public class SharedResourceHolderTest {
|
||||||
@Test public void cancelDestroyTask() {
|
@Test public void cancelDestroyTask() {
|
||||||
ResourceInstance foo1 = holder.getInternal(SHARED_FOO);
|
ResourceInstance foo1 = holder.getInternal(SHARED_FOO);
|
||||||
ResourceInstance sharedFoo = foo1;
|
ResourceInstance sharedFoo = foo1;
|
||||||
foo1 = holder.releaseInternal(SHARED_FOO, foo1);
|
holder.releaseInternal(SHARED_FOO, foo1);
|
||||||
// A destroying task for foo is scheduled
|
// A destroying task for foo is scheduled
|
||||||
MockScheduledFuture<?> scheduledDestroyTask = scheduledDestroyTasks.poll();
|
MockScheduledFuture<?> scheduledDestroyTask = scheduledDestroyTasks.poll();
|
||||||
assertFalse(scheduledDestroyTask.cancelled);
|
assertFalse(scheduledDestroyTask.cancelled);
|
||||||
|
|
@ -137,7 +137,7 @@ public class SharedResourceHolderTest {
|
||||||
assertSame(sharedFoo, foo2);
|
assertSame(sharedFoo, foo2);
|
||||||
|
|
||||||
// Release it and the destroying task is scheduled again
|
// Release it and the destroying task is scheduled again
|
||||||
foo2 = holder.releaseInternal(SHARED_FOO, foo2);
|
holder.releaseInternal(SHARED_FOO, foo2);
|
||||||
scheduledDestroyTask = scheduledDestroyTasks.poll();
|
scheduledDestroyTask = scheduledDestroyTasks.poll();
|
||||||
assertFalse(scheduledDestroyTask.cancelled);
|
assertFalse(scheduledDestroyTask.cancelled);
|
||||||
scheduledDestroyTask.runTask();
|
scheduledDestroyTask.runTask();
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ import io.grpc.testing.GrpcCleanupRule;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.List;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
|
@ -133,7 +133,7 @@ public class RouteGuideServerTest {
|
||||||
features.add(f2);
|
features.add(f2);
|
||||||
features.add(f3);
|
features.add(f3);
|
||||||
features.add(f4);
|
features.add(f4);
|
||||||
final Collection<Feature> result = new HashSet<Feature>();
|
final List<Feature> result = new ArrayList<Feature>();
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
StreamObserver<Feature> responseObserver =
|
StreamObserver<Feature> responseObserver =
|
||||||
new StreamObserver<Feature>() {
|
new StreamObserver<Feature>() {
|
||||||
|
|
@ -159,7 +159,7 @@ public class RouteGuideServerTest {
|
||||||
assertTrue(latch.await(1, TimeUnit.SECONDS));
|
assertTrue(latch.await(1, TimeUnit.SECONDS));
|
||||||
|
|
||||||
// verify
|
// verify
|
||||||
assertEquals(new HashSet<>(Arrays.asList(f2, f3)), result);
|
assertEquals(Arrays.asList(f2, f3), result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@ import io.grpc.LoadBalancerRegistry;
|
||||||
import io.grpc.internal.JsonParser;
|
import io.grpc.internal.JsonParser;
|
||||||
import io.grpc.internal.ServiceConfigUtil;
|
import io.grpc.internal.ServiceConfigUtil;
|
||||||
import io.grpc.internal.ServiceConfigUtil.LbConfig;
|
import io.grpc.internal.ServiceConfigUtil.LbConfig;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
|
|
@ -157,11 +156,6 @@ public class XdsLoadBalancerProviderTest {
|
||||||
assertEquals(expectedFallbackPolicy, fallbackPolicy);
|
assertEquals(expectedFallbackPolicy, fallbackPolicy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private static List<Map<String, ?>> checkObjectList(Object o) {
|
|
||||||
return (List<Map<String, ?>>) o;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private static Map<String, ?> checkObject(Object o) {
|
private static Map<String, ?> checkObject(Object o) {
|
||||||
return (Map<String, ?>) o;
|
return (Map<String, ?>) o;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue