mirror of https://github.com/grpc/grpc-java.git
all: fix lint
This commit is contained in:
parent
56e980cb29
commit
df21e40285
|
|
@ -37,7 +37,7 @@ import org.junit.runners.JUnit4;
|
||||||
public final class HandshakerServiceChannelTest {
|
public final class HandshakerServiceChannelTest {
|
||||||
@Rule
|
@Rule
|
||||||
public final GrpcCleanupRule grpcCleanup = new GrpcCleanupRule();
|
public final GrpcCleanupRule grpcCleanup = new GrpcCleanupRule();
|
||||||
private Server server = grpcCleanup.register(
|
private final Server server = grpcCleanup.register(
|
||||||
ServerBuilder.forPort(0)
|
ServerBuilder.forPort(0)
|
||||||
.addService(new SimpleServiceGrpc.SimpleServiceImplBase() {
|
.addService(new SimpleServiceGrpc.SimpleServiceImplBase() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,8 @@ public class TsiFrameHandlerTest {
|
||||||
try {
|
try {
|
||||||
channel.checkException();
|
channel.checkException();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new AssertionError("Any attempt after close should be ignored without out exception");
|
throw new AssertionError(
|
||||||
|
"Any attempt after close should be ignored without out exception", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ public interface Codec extends Compressor, Decompressor {
|
||||||
* A gzip compressor and decompressor. In the future this will likely support other
|
* A gzip compressor and decompressor. In the future this will likely support other
|
||||||
* compression methods, such as compression level.
|
* compression methods, such as compression level.
|
||||||
*/
|
*/
|
||||||
public static final class Gzip implements Codec {
|
final class Gzip implements Codec {
|
||||||
@Override
|
@Override
|
||||||
public String getMessageEncoding() {
|
public String getMessageEncoding() {
|
||||||
return "gzip";
|
return "gzip";
|
||||||
|
|
@ -53,7 +53,7 @@ public interface Codec extends Compressor, Decompressor {
|
||||||
* The "identity", or "none" codec. This codec is special in that it can be used to explicitly
|
* The "identity", or "none" codec. This codec is special in that it can be used to explicitly
|
||||||
* disable Call compression on a Channel that by default compresses.
|
* disable Call compression on a Channel that by default compresses.
|
||||||
*/
|
*/
|
||||||
public static final class Identity implements Codec {
|
final class Identity implements Codec {
|
||||||
/**
|
/**
|
||||||
* Special sentinel codec indicating that no compression should be used. Users should use
|
* Special sentinel codec indicating that no compression should be used. Users should use
|
||||||
* reference equality to see if compression is disabled.
|
* reference equality to see if compression is disabled.
|
||||||
|
|
@ -61,7 +61,7 @@ public interface Codec extends Compressor, Decompressor {
|
||||||
public static final Codec NONE = new Identity();
|
public static final Codec NONE = new Identity();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InputStream decompress(InputStream is) throws IOException {
|
public InputStream decompress(InputStream is) {
|
||||||
return is;
|
return is;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -71,7 +71,7 @@ public interface Codec extends Compressor, Decompressor {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OutputStream compress(OutputStream os) throws IOException {
|
public OutputStream compress(OutputStream os) {
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,15 @@
|
||||||
|
|
||||||
package io.grpc.examples.authentication;
|
package io.grpc.examples.authentication;
|
||||||
|
|
||||||
import io.grpc.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.mockito.AdditionalAnswers.delegatesTo;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
|
import io.grpc.Metadata;
|
||||||
|
import io.grpc.ServerCall;
|
||||||
|
import io.grpc.ServerCallHandler;
|
||||||
|
import io.grpc.ServerInterceptors;
|
||||||
import io.grpc.examples.helloworld.GreeterGrpc;
|
import io.grpc.examples.helloworld.GreeterGrpc;
|
||||||
import io.grpc.examples.helloworld.HelloReply;
|
import io.grpc.examples.helloworld.HelloReply;
|
||||||
import io.grpc.examples.helloworld.HelloRequest;
|
import io.grpc.examples.helloworld.HelloRequest;
|
||||||
|
|
@ -24,7 +32,9 @@ import io.grpc.inprocess.InProcessChannelBuilder;
|
||||||
import io.grpc.inprocess.InProcessServerBuilder;
|
import io.grpc.inprocess.InProcessServerBuilder;
|
||||||
import io.grpc.ServerCall.Listener;
|
import io.grpc.ServerCall.Listener;
|
||||||
import io.grpc.ServerInterceptor;
|
import io.grpc.ServerInterceptor;
|
||||||
|
import io.grpc.stub.StreamObserver;
|
||||||
import io.grpc.testing.GrpcCleanupRule;
|
import io.grpc.testing.GrpcCleanupRule;
|
||||||
|
import java.io.IOException;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
@ -33,13 +43,6 @@ import org.junit.runners.JUnit4;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
import org.mockito.Matchers;
|
import org.mockito.Matchers;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.mockito.AdditionalAnswers.delegatesTo;
|
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.verify;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit tests for {@link AuthClient} testing the default and non-default tokens
|
* Unit tests for {@link AuthClient} testing the default and non-default tokens
|
||||||
*
|
*
|
||||||
|
|
@ -73,16 +76,19 @@ public class AuthClientTest {
|
||||||
|
|
||||||
// Create a server, add service, start, and register for automatic graceful shutdown.
|
// Create a server, add service, start, and register for automatic graceful shutdown.
|
||||||
grpcCleanup.register(InProcessServerBuilder.forName(serverName).directExecutor()
|
grpcCleanup.register(InProcessServerBuilder.forName(serverName).directExecutor()
|
||||||
.addService(ServerInterceptors.intercept(new GreeterGrpc.GreeterImplBase() {
|
.addService(ServerInterceptors.intercept(
|
||||||
|
new GreeterGrpc.GreeterImplBase() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sayHello(io.grpc.examples.helloworld.HelloRequest request,
|
public void sayHello(
|
||||||
io.grpc.stub.StreamObserver<io.grpc.examples.helloworld.HelloReply> responseObserver) {
|
HelloRequest request, StreamObserver<HelloReply> responseObserver) {
|
||||||
HelloReply reply = HelloReply.newBuilder().setMessage("AuthClientTest user=" + request.getName()).build();
|
HelloReply reply = HelloReply.newBuilder()
|
||||||
|
.setMessage("AuthClientTest user=" + request.getName()).build();
|
||||||
responseObserver.onNext(reply);
|
responseObserver.onNext(reply);
|
||||||
responseObserver.onCompleted();
|
responseObserver.onCompleted();
|
||||||
}
|
}
|
||||||
}, mockServerInterceptor))
|
},
|
||||||
|
mockServerInterceptor))
|
||||||
.build().start());
|
.build().start());
|
||||||
|
|
||||||
// Create an AuthClient using the in-process channel;
|
// Create an AuthClient using the in-process channel;
|
||||||
|
|
@ -90,12 +96,10 @@ public class AuthClientTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test default JWT token used
|
* Test default JWT token used.
|
||||||
*
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void defaultTokenDeliveredToServer() throws Exception {
|
public void defaultTokenDeliveredToServer() {
|
||||||
ArgumentCaptor<Metadata> metadataCaptor = ArgumentCaptor.forClass(Metadata.class);
|
ArgumentCaptor<Metadata> metadataCaptor = ArgumentCaptor.forClass(Metadata.class);
|
||||||
ArgumentCaptor<HelloRequest> requestCaptor = ArgumentCaptor.forClass(HelloRequest.class);
|
ArgumentCaptor<HelloRequest> requestCaptor = ArgumentCaptor.forClass(HelloRequest.class);
|
||||||
|
|
||||||
|
|
@ -112,12 +116,10 @@ public class AuthClientTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test non-default JWT token used
|
* Test non-default JWT token used.
|
||||||
*
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void nonDefaultTokenDeliveredToServer() throws Exception {
|
public void nonDefaultTokenDeliveredToServer() {
|
||||||
ArgumentCaptor<Metadata> metadataCaptor = ArgumentCaptor.forClass(Metadata.class);
|
ArgumentCaptor<Metadata> metadataCaptor = ArgumentCaptor.forClass(Metadata.class);
|
||||||
ArgumentCaptor<HelloRequest> requestCaptor = ArgumentCaptor.forClass(HelloRequest.class);
|
ArgumentCaptor<HelloRequest> requestCaptor = ArgumentCaptor.forClass(HelloRequest.class);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -182,7 +182,7 @@ class OkHttpClientTransport implements ConnectionClientTransport, TransportExcep
|
||||||
private int maxConcurrentStreams = 0;
|
private int maxConcurrentStreams = 0;
|
||||||
@SuppressWarnings("JdkObsolete") // Usage is bursty; want low memory usage when empty
|
@SuppressWarnings("JdkObsolete") // Usage is bursty; want low memory usage when empty
|
||||||
@GuardedBy("lock")
|
@GuardedBy("lock")
|
||||||
private LinkedList<OkHttpClientStream> pendingStreams = new LinkedList<>();
|
private final LinkedList<OkHttpClientStream> pendingStreams = new LinkedList<>();
|
||||||
private final ConnectionSpec connectionSpec;
|
private final ConnectionSpec connectionSpec;
|
||||||
private FrameWriter testFrameWriter;
|
private FrameWriter testFrameWriter;
|
||||||
private ScheduledExecutorService scheduler;
|
private ScheduledExecutorService scheduler;
|
||||||
|
|
|
||||||
|
|
@ -51,11 +51,11 @@ import org.mockito.InOrder;
|
||||||
@RunWith(JUnit4.class)
|
@RunWith(JUnit4.class)
|
||||||
public class AsyncSinkTest {
|
public class AsyncSinkTest {
|
||||||
|
|
||||||
private Socket socket = mock(Socket.class);
|
private final Socket socket = mock(Socket.class);
|
||||||
private Sink mockedSink = mock(VoidSink.class, CALLS_REAL_METHODS);
|
private final Sink mockedSink = mock(VoidSink.class, CALLS_REAL_METHODS);
|
||||||
private QueueingExecutor queueingExecutor = new QueueingExecutor();
|
private final QueueingExecutor queueingExecutor = new QueueingExecutor();
|
||||||
private TransportExceptionHandler exceptionHandler = mock(TransportExceptionHandler.class);
|
private final TransportExceptionHandler exceptionHandler = mock(TransportExceptionHandler.class);
|
||||||
private AsyncSink sink =
|
private final AsyncSink sink =
|
||||||
AsyncSink.sink(new SerializingExecutor(queueingExecutor), exceptionHandler);
|
AsyncSink.sink(new SerializingExecutor(queueingExecutor), exceptionHandler);
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
|
|
|
||||||
|
|
@ -35,10 +35,10 @@ import org.junit.runners.JUnit4;
|
||||||
@RunWith(JUnit4.class)
|
@RunWith(JUnit4.class)
|
||||||
public class ExceptionHandlingFrameWriterTest {
|
public class ExceptionHandlingFrameWriterTest {
|
||||||
|
|
||||||
private FrameWriter mockedFrameWriter = mock(FrameWriter.class);
|
private final FrameWriter mockedFrameWriter = mock(FrameWriter.class);
|
||||||
private TransportExceptionHandler transportExceptionHandler =
|
private final TransportExceptionHandler transportExceptionHandler =
|
||||||
mock(TransportExceptionHandler.class);
|
mock(TransportExceptionHandler.class);
|
||||||
private ExceptionHandlingFrameWriter exceptionHandlingFrameWriter =
|
private final ExceptionHandlingFrameWriter exceptionHandlingFrameWriter =
|
||||||
new ExceptionHandlingFrameWriter(transportExceptionHandler, mockedFrameWriter);
|
new ExceptionHandlingFrameWriter(transportExceptionHandler, mockedFrameWriter);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -2117,7 +2117,7 @@ public class OkHttpClientTransportTest {
|
||||||
private static class MockFrameWriter implements FrameWriter {
|
private static class MockFrameWriter implements FrameWriter {
|
||||||
|
|
||||||
private Socket socket;
|
private Socket socket;
|
||||||
private Queue<Buffer> capturedBuffer;
|
private final Queue<Buffer> capturedBuffer;
|
||||||
|
|
||||||
public MockFrameWriter(Socket socket, Queue<Buffer> capturedBuffer) {
|
public MockFrameWriter(Socket socket, Queue<Buffer> capturedBuffer) {
|
||||||
// Sets a socket to close. Some tests assumes that FrameWriter will close underlying sink
|
// Sets a socket to close. Some tests assumes that FrameWriter will close underlying sink
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ final class ProtoInputStream extends InputStream implements Drainable, KnownLeng
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int read() throws IOException {
|
public int read() {
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
partial = new ByteArrayInputStream(message.toByteArray());
|
partial = new ByteArrayInputStream(message.toByteArray());
|
||||||
message = null;
|
message = null;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue