Fix lint warnings

This commit is contained in:
Eric Anderson 2020-08-07 09:17:19 -07:00 committed by Eric Anderson
parent 47301752b1
commit 020fb36753
5 changed files with 16 additions and 19 deletions

View File

@ -284,7 +284,6 @@ public class ServerInterceptorsTest {
@Test @Test
public void argumentsPassed() { public void argumentsPassed() {
@SuppressWarnings("unchecked")
final ServerCall<String, Integer> call2 = new NoopServerCall<>(); final ServerCall<String, Integer> call2 = new NoopServerCall<>();
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
final ServerCall.Listener<String> listener2 = mock(ServerCall.Listener.class); final ServerCall.Listener<String> listener2 = mock(ServerCall.Listener.class);

View File

@ -199,7 +199,6 @@ public class CensusModulesTest {
private CensusTracingModule censusTracing; private CensusTracingModule censusTracing;
@Before @Before
@SuppressWarnings("unchecked")
public void setUp() throws Exception { public void setUp() throws Exception {
when(spyClientSpanBuilder.startSpan()).thenReturn(spyClientSpan); when(spyClientSpanBuilder.startSpan()).thenReturn(spyClientSpan);
when(tracer.spanBuilderWithExplicitParent(anyString(), ArgumentMatchers.<Span>any())) when(tracer.spanBuilderWithExplicitParent(anyString(), ArgumentMatchers.<Span>any()))

View File

@ -969,7 +969,6 @@ public class Context {
/** /**
* Get the value from the {@link #current()} context for this key. * Get the value from the {@link #current()} context for this key.
*/ */
@SuppressWarnings("unchecked")
public T get() { public T get() {
return get(Context.current()); return get(Context.current());
} }

View File

@ -140,7 +140,6 @@ import org.junit.Assert;
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.ArgumentCaptor; import org.mockito.ArgumentCaptor;
@ -210,7 +209,6 @@ public class ManagedChannelImplTest {
private final InternalChannelz channelz = new InternalChannelz(); private final InternalChannelz channelz = new InternalChannelz();
@Rule public final ExpectedException thrown = ExpectedException.none();
@Rule public final MockitoRule mocks = MockitoJUnit.rule(); @Rule public final MockitoRule mocks = MockitoJUnit.rule();
private ManagedChannelImpl channel; private ManagedChannelImpl channel;

View File

@ -927,11 +927,11 @@ public final class BinlogHelperTest {
} }
@Test @Test
@SuppressWarnings({"rawtypes", "unchecked"})
public void serverDeadlineLogged() { public void serverDeadlineLogged() {
final AtomicReference<ServerCall> interceptedCall = final AtomicReference<ServerCall<byte[], byte[]>> interceptedCall =
new AtomicReference<>(); new AtomicReference<>();
final ServerCall.Listener mockListener = mock(ServerCall.Listener.class); @SuppressWarnings("unchecked")
final ServerCall.Listener<byte[]> mockListener = mock(ServerCall.Listener.class);
final MethodDescriptor<byte[], byte[]> method = final MethodDescriptor<byte[], byte[]> method =
MethodDescriptor.<byte[], byte[]>newBuilder() MethodDescriptor.<byte[], byte[]>newBuilder()
@ -986,7 +986,6 @@ public final class BinlogHelperTest {
} }
@Test @Test
@SuppressWarnings({"unchecked"})
public void clientDeadlineLogged_deadlineSetViaCallOption() { public void clientDeadlineLogged_deadlineSetViaCallOption() {
MethodDescriptor<byte[], byte[]> method = MethodDescriptor<byte[], byte[]> method =
MethodDescriptor.<byte[], byte[]>newBuilder() MethodDescriptor.<byte[], byte[]>newBuilder()
@ -995,6 +994,7 @@ public final class BinlogHelperTest {
.setRequestMarshaller(BYTEARRAY_MARSHALLER) .setRequestMarshaller(BYTEARRAY_MARSHALLER)
.setResponseMarshaller(BYTEARRAY_MARSHALLER) .setResponseMarshaller(BYTEARRAY_MARSHALLER)
.build(); .build();
@SuppressWarnings("unchecked")
ClientCall.Listener<byte[]> mockListener = mock(ClientCall.Listener.class); ClientCall.Listener<byte[]> mockListener = mock(ClientCall.Listener.class);
ClientCall<byte[], byte[]> call = ClientCall<byte[], byte[]> call =
@ -1035,7 +1035,6 @@ public final class BinlogHelperTest {
} }
@Test @Test
@SuppressWarnings({"unchecked"})
public void clientDeadlineLogged_deadlineSetViaContext() throws Exception { public void clientDeadlineLogged_deadlineSetViaContext() throws Exception {
// important: deadline is read from the ctx where call was created // important: deadline is read from the ctx where call was created
final SettableFuture<ClientCall<byte[], byte[]>> callFuture = SettableFuture.create(); final SettableFuture<ClientCall<byte[], byte[]>> callFuture = SettableFuture.create();
@ -1073,6 +1072,7 @@ public final class BinlogHelperTest {
})); }));
} }
}); });
@SuppressWarnings("unchecked")
ClientCall.Listener<byte[]> mockListener = mock(ClientCall.Listener.class); ClientCall.Listener<byte[]> mockListener = mock(ClientCall.Listener.class);
callFuture.get().start(mockListener, new Metadata()); callFuture.get().start(mockListener, new Metadata());
ArgumentCaptor<Duration> callOptTimeoutCaptor = ArgumentCaptor.forClass(Duration.class); ArgumentCaptor<Duration> callOptTimeoutCaptor = ArgumentCaptor.forClass(Duration.class);
@ -1093,9 +1093,8 @@ public final class BinlogHelperTest {
} }
@Test @Test
@SuppressWarnings({"rawtypes", "unchecked"})
public void clientInterceptor() throws Exception { public void clientInterceptor() throws Exception {
final AtomicReference<ClientCall.Listener> interceptedListener = final AtomicReference<ClientCall.Listener<byte[]>> interceptedListener =
new AtomicReference<>(); new AtomicReference<>();
// capture these manually because ClientCall can not be mocked // capture these manually because ClientCall can not be mocked
final AtomicReference<Metadata> actualClientInitial = new AtomicReference<>(); final AtomicReference<Metadata> actualClientInitial = new AtomicReference<>();
@ -1109,8 +1108,9 @@ public final class BinlogHelperTest {
MethodDescriptor<RequestT, ResponseT> methodDescriptor, CallOptions callOptions) { MethodDescriptor<RequestT, ResponseT> methodDescriptor, CallOptions callOptions) {
return new NoopClientCall<RequestT, ResponseT>() { return new NoopClientCall<RequestT, ResponseT>() {
@Override @Override
@SuppressWarnings("unchecked")
public void start(Listener<ResponseT> responseListener, Metadata headers) { public void start(Listener<ResponseT> responseListener, Metadata headers) {
interceptedListener.set(responseListener); interceptedListener.set((Listener<byte[]>) responseListener);
actualClientInitial.set(headers); actualClientInitial.set(headers);
} }
@ -1142,6 +1142,7 @@ public final class BinlogHelperTest {
} }
}; };
@SuppressWarnings("unchecked")
ClientCall.Listener<byte[]> mockListener = mock(ClientCall.Listener.class); ClientCall.Listener<byte[]> mockListener = mock(ClientCall.Listener.class);
MethodDescriptor<byte[], byte[]> method = MethodDescriptor<byte[], byte[]> method =
@ -1260,9 +1261,8 @@ public final class BinlogHelperTest {
} }
@Test @Test
@SuppressWarnings({"rawtypes", "unchecked"})
public void clientInterceptor_trailersOnlyResponseLogsPeerAddress() throws Exception { public void clientInterceptor_trailersOnlyResponseLogsPeerAddress() throws Exception {
final AtomicReference<ClientCall.Listener> interceptedListener = final AtomicReference<ClientCall.Listener<byte[]>> interceptedListener =
new AtomicReference<>(); new AtomicReference<>();
// capture these manually because ClientCall can not be mocked // capture these manually because ClientCall can not be mocked
final AtomicReference<Metadata> actualClientInitial = new AtomicReference<>(); final AtomicReference<Metadata> actualClientInitial = new AtomicReference<>();
@ -1274,8 +1274,9 @@ public final class BinlogHelperTest {
MethodDescriptor<RequestT, ResponseT> methodDescriptor, CallOptions callOptions) { MethodDescriptor<RequestT, ResponseT> methodDescriptor, CallOptions callOptions) {
return new NoopClientCall<RequestT, ResponseT>() { return new NoopClientCall<RequestT, ResponseT>() {
@Override @Override
@SuppressWarnings("unchecked")
public void start(Listener<ResponseT> responseListener, Metadata headers) { public void start(Listener<ResponseT> responseListener, Metadata headers) {
interceptedListener.set(responseListener); interceptedListener.set((Listener<byte[]>) responseListener);
actualClientInitial.set(headers); actualClientInitial.set(headers);
} }
@ -1297,6 +1298,7 @@ public final class BinlogHelperTest {
} }
}; };
@SuppressWarnings("unchecked")
ClientCall.Listener<byte[]> mockListener = mock(ClientCall.Listener.class); ClientCall.Listener<byte[]> mockListener = mock(ClientCall.Listener.class);
MethodDescriptor<byte[], byte[]> method = MethodDescriptor<byte[], byte[]> method =
@ -1345,12 +1347,12 @@ public final class BinlogHelperTest {
} }
@Test @Test
@SuppressWarnings({"rawtypes", "unchecked"})
public void serverInterceptor() throws Exception { public void serverInterceptor() throws Exception {
final AtomicReference<ServerCall> interceptedCall = final AtomicReference<ServerCall<byte[], byte[]>> interceptedCall =
new AtomicReference<>(); new AtomicReference<>();
ServerCall.Listener<byte[]> capturedListener; ServerCall.Listener<byte[]> capturedListener;
final ServerCall.Listener mockListener = mock(ServerCall.Listener.class); @SuppressWarnings("unchecked")
final ServerCall.Listener<byte[]> mockListener = mock(ServerCall.Listener.class);
// capture these manually because ServerCall can not be mocked // capture these manually because ServerCall can not be mocked
final AtomicReference<Metadata> actualServerInitial = new AtomicReference<>(); final AtomicReference<Metadata> actualServerInitial = new AtomicReference<>();
final AtomicReference<byte[]> actualResponse = new AtomicReference<>(); final AtomicReference<byte[]> actualResponse = new AtomicReference<>();