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