mirror of https://github.com/grpc/grpc-java.git
Cleaning up some warnings.
This commit is contained in:
parent
c5612217d1
commit
7779b4fddf
|
|
@ -102,7 +102,6 @@ public class ClientAuthInterceptorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testCopyCredentialToHeaders() throws IOException {
|
||||
ListMultimap<String, String> values = LinkedListMultimap.create();
|
||||
values.put("Authorization", "token1");
|
||||
|
|
@ -110,7 +109,7 @@ public class ClientAuthInterceptorTests {
|
|||
values.put("Extra-Authorization", "token3");
|
||||
values.put("Extra-Authorization", "token4");
|
||||
when(credentials.getRequestMetadata()).thenReturn(Multimaps.asMap(values));
|
||||
Call interceptedCall = interceptor.interceptCall(descriptor, channel);
|
||||
Call<String, Integer> interceptedCall = interceptor.interceptCall(descriptor, channel);
|
||||
Metadata.Headers headers = new Metadata.Headers();
|
||||
interceptedCall.start(listener, headers);
|
||||
verify(call).start(listener, headers);
|
||||
|
|
@ -124,10 +123,9 @@ public class ClientAuthInterceptorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testCredentialsThrows() throws IOException {
|
||||
when(credentials.getRequestMetadata()).thenThrow(new IOException("Broken"));
|
||||
Call interceptedCall = interceptor.interceptCall(descriptor, channel);
|
||||
Call<String, Integer> interceptedCall = interceptor.interceptCall(descriptor, channel);
|
||||
Metadata.Headers headers = new Metadata.Headers();
|
||||
interceptedCall.start(listener, headers);
|
||||
ArgumentCaptor<Status> statusCaptor = ArgumentCaptor.forClass(Status.class);
|
||||
|
|
@ -139,7 +137,6 @@ public class ClientAuthInterceptorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testWithOAuth2Credential() throws IOException {
|
||||
final AccessToken token = new AccessToken("allyourbase", new Date(Long.MAX_VALUE));
|
||||
final OAuth2Credentials oAuth2Credentials = new OAuth2Credentials() {
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ public abstract class AbstractBenchmark {
|
|||
protected ServerImpl server;
|
||||
protected ByteBuf request;
|
||||
protected ByteBuf response;
|
||||
protected MethodDescriptor unaryMethod;
|
||||
protected MethodDescriptor<ByteBuf, ByteBuf> unaryMethod;
|
||||
protected ChannelImpl[] channels;
|
||||
|
||||
public AbstractBenchmark() {
|
||||
|
|
@ -215,9 +215,9 @@ public abstract class AbstractBenchmark {
|
|||
final AtomicBoolean done) {
|
||||
for (final ChannelImpl channel : channels) {
|
||||
for (int i = 0; i < callsPerChannel; i++) {
|
||||
StreamObserver observer = new StreamObserver() {
|
||||
StreamObserver<ByteBuf> observer = new StreamObserver<ByteBuf>() {
|
||||
@Override
|
||||
public void onValue(Object value) {
|
||||
public void onValue(ByteBuf value) {
|
||||
counter.incrementAndGet();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -452,7 +452,7 @@ public final class Status {
|
|||
* Exception thrown by implementations while managing an operation.
|
||||
*/
|
||||
public static class OperationException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = -660954903976144640L;
|
||||
private final Status status;
|
||||
|
||||
public OperationException(Status status) {
|
||||
|
|
@ -469,7 +469,7 @@ public final class Status {
|
|||
* Runtime exception thrown by implementations while managing an operation.
|
||||
*/
|
||||
public static class OperationRuntimeException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 1950934672280720624L;
|
||||
private final Status status;
|
||||
|
||||
public OperationRuntimeException(Status status) {
|
||||
|
|
|
|||
|
|
@ -196,9 +196,9 @@ public class SharedResourceHolderTest {
|
|||
public ScheduledExecutorService createScheduledExecutor() {
|
||||
ScheduledExecutorService mockExecutor = mock(ScheduledExecutorService.class);
|
||||
when(mockExecutor.schedule(any(Runnable.class), anyLong(), any(TimeUnit.class))).thenAnswer(
|
||||
new Answer() {
|
||||
new Answer<MockScheduledFuture<Void>>() {
|
||||
@Override
|
||||
public Object answer(InvocationOnMock invocation) {
|
||||
public MockScheduledFuture<Void> answer(InvocationOnMock invocation) {
|
||||
Object[] args = invocation.getArguments();
|
||||
Runnable command = (Runnable) args[0];
|
||||
long delay = (Long) args[1];
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ package io.grpc.transport.netty;
|
|||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
class GoAwayClosedStreamException extends Exception {
|
||||
private static final long serialVersionUID = 1326785622777291198L;
|
||||
private final int lastStreamId;
|
||||
private final long errorCode;
|
||||
private final ByteBuf debugData;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,9 @@ package io.grpc.transport.okhttp;
|
|||
|
||||
import io.grpc.transport.ReadableBuffer;
|
||||
import io.grpc.transport.ReadableBufferTestBase;
|
||||
|
||||
import okio.Buffer;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
|
@ -47,6 +49,7 @@ public class OkHttpReadableBufferTest extends ReadableBufferTestBase {
|
|||
|
||||
private OkHttpReadableBuffer buffer;
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
@Before
|
||||
public void setup() {
|
||||
buffer = new OkHttpReadableBuffer(new Buffer().writeUtf8(msg));
|
||||
|
|
|
|||
|
|
@ -327,9 +327,9 @@ public class Calls {
|
|||
}
|
||||
|
||||
private static class GrpcFuture<RespT> extends AbstractFuture<RespT> {
|
||||
private final Call call;
|
||||
private final Call<?, RespT> call;
|
||||
|
||||
GrpcFuture(Call call) {
|
||||
GrpcFuture(Call<?, RespT> call) {
|
||||
this.call = call;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -108,7 +108,6 @@ public class MetadataUtils {
|
|||
* @param trailersCapture to record the last received trailers
|
||||
* @return an implementation of the channel with captures installed.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static ClientInterceptor newCaptureMetadataInterceptor(
|
||||
final AtomicReference<Metadata.Headers> headersCapture,
|
||||
final AtomicReference<Metadata.Trailers> trailersCapture) {
|
||||
|
|
|
|||
|
|
@ -65,11 +65,10 @@ public class CallsTest {
|
|||
MockitoAnnotations.initMocks(this);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test public void unaryFutureCallSuccess() throws Exception {
|
||||
Integer req = 2;
|
||||
ListenableFuture<String> future = Calls.unaryFutureCall(call, req);
|
||||
ArgumentCaptor<Call.Listener> listenerCaptor = ArgumentCaptor.forClass(Call.Listener.class);
|
||||
ArgumentCaptor<Call.Listener<String>> listenerCaptor = ArgumentCaptor.forClass(null);
|
||||
verify(call).start(listenerCaptor.capture(), any(Metadata.Headers.class));
|
||||
Call.Listener<String> listener = listenerCaptor.getValue();
|
||||
verify(call).sendPayload(req);
|
||||
|
|
@ -79,11 +78,10 @@ public class CallsTest {
|
|||
assertEquals("bar", future.get());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test public void unaryFutureCallFailed() throws Exception {
|
||||
Integer req = 2;
|
||||
ListenableFuture<String> future = Calls.unaryFutureCall(call, req);
|
||||
ArgumentCaptor<Call.Listener> listenerCaptor = ArgumentCaptor.forClass(Call.Listener.class);
|
||||
ArgumentCaptor<Call.Listener<String>> listenerCaptor = ArgumentCaptor.forClass(null);
|
||||
verify(call).start(listenerCaptor.capture(), any(Metadata.Headers.class));
|
||||
Call.Listener<String> listener = listenerCaptor.getValue();
|
||||
listener.onClose(Status.INVALID_ARGUMENT, new Metadata.Trailers());
|
||||
|
|
@ -96,11 +94,10 @@ public class CallsTest {
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test public void unaryFutureCallCancelled() throws Exception {
|
||||
Integer req = 2;
|
||||
ListenableFuture<String> future = Calls.unaryFutureCall(call, req);
|
||||
ArgumentCaptor<Call.Listener> listenerCaptor = ArgumentCaptor.forClass(Call.Listener.class);
|
||||
ArgumentCaptor<Call.Listener<String>> listenerCaptor = ArgumentCaptor.forClass(null);
|
||||
verify(call).start(listenerCaptor.capture(), any(Metadata.Headers.class));
|
||||
Call.Listener<String> listener = listenerCaptor.getValue();
|
||||
future.cancel(true);
|
||||
|
|
|
|||
Loading…
Reference in New Issue