From 76d0955a6e9be049c8e9dee87890afa6b588a7f5 Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Thu, 12 Mar 2015 15:25:11 -0700 Subject: [PATCH] Clean up warnings -Xlint:-options is not available on some earlier JDK 7s, but won't fail if unsupported. It prevents the warning wanting bootclasspath specified since target/source is 1.6. --- .../java/io/grpc/auth/ClientAuthInterceptorTests.java | 8 ++++---- build.gradle | 6 +++--- compiler/src/java_plugin/cpp/java_generator.cpp | 3 ++- compiler/src/test/golden/TestService.java.txt | 1 + compiler/src/test/golden/TestServiceNano.java.txt | 1 + core/src/main/java/io/grpc/Status.java | 2 ++ .../main/java/io/grpc/transport/AbstractClientStream.java | 2 ++ core/src/main/java/io/grpc/transport/AbstractStream.java | 2 ++ core/src/test/java/io/grpc/ClientInterceptorsTest.java | 4 +++- .../java/io/grpc/testing/integration/TestServiceGrpc.java | 1 + 10 files changed, 21 insertions(+), 9 deletions(-) diff --git a/auth/src/test/java/io/grpc/auth/ClientAuthInterceptorTests.java b/auth/src/test/java/io/grpc/auth/ClientAuthInterceptorTests.java index 34914ff11e..6bbe719f98 100644 --- a/auth/src/test/java/io/grpc/auth/ClientAuthInterceptorTests.java +++ b/auth/src/test/java/io/grpc/auth/ClientAuthInterceptorTests.java @@ -48,16 +48,16 @@ public class ClientAuthInterceptorTests { Credentials credentials; @Mock - MethodDescriptor descriptor; + MethodDescriptor descriptor; @Mock - Call.Listener listener; + Call.Listener listener; @Mock Channel channel; @Mock - Call call; + Call call; ClientAuthInterceptor interceptor; @@ -117,7 +117,7 @@ public class ClientAuthInterceptorTests { } }; interceptor = new ClientAuthInterceptor(oAuth2Credentials, Executors.newSingleThreadExecutor()); - Call interceptedCall = interceptor.interceptCall(descriptor, channel); + Call interceptedCall = interceptor.interceptCall(descriptor, channel); Metadata.Headers headers = new Metadata.Headers(); interceptedCall.start(listener, headers); verify(call).start(listener, headers); diff --git a/build.gradle b/build.gradle index 2ec75c0534..3fdc10434f 100644 --- a/build.gradle +++ b/build.gradle @@ -17,9 +17,9 @@ subprojects { mavenLocal() } - compileJava { - options.compilerArgs << "-Xlint:unchecked" - options.encoding = "UTF-8" + [compileJava, compileTestJava].each() { + it.options.compilerArgs += ["-Xlint:unchecked", "-Xlint:deprecation", "-Xlint:-options"] + it.options.encoding = "UTF-8" } javadoc.options.encoding = "UTF-8" diff --git a/compiler/src/java_plugin/cpp/java_generator.cpp b/compiler/src/java_plugin/cpp/java_generator.cpp index b2b3894e94..e74f18e84e 100644 --- a/compiler/src/java_plugin/cpp/java_generator.cpp +++ b/compiler/src/java_plugin/cpp/java_generator.cpp @@ -167,7 +167,8 @@ static void PrintServiceDescriptor( // The reconfiguring constructor p->Print( *vars, - "\nprivate $service_name$ServiceDescriptor(\n" + "\n@SuppressWarnings(\"unchecked\")\n" + "private $service_name$ServiceDescriptor(\n" " $Map$<$String$, $MethodDescriptor$> methodMap) {\n"); p->Indent(); for (int i = 0; i < service->method_count(); ++i) { diff --git a/compiler/src/test/golden/TestService.java.txt b/compiler/src/test/golden/TestService.java.txt index 46f71165a2..a19f90c397 100644 --- a/compiler/src/test/golden/TestService.java.txt +++ b/compiler/src/test/golden/TestService.java.txt @@ -90,6 +90,7 @@ public class TestServiceGrpc { "grpc.testing.TestService", METHOD_HALF_DUPLEX_CALL); } + @SuppressWarnings("unchecked") private TestServiceServiceDescriptor( java.util.Map> methodMap) { unaryCall = (io.grpc.MethodDescriptor> methodMap) { unaryCall = (io.grpc.MethodDescriptor extends AbstractStream */ protected abstract void sendCancel(); + // We support Guava 14 + @SuppressWarnings("deprecation") @Override protected Objects.ToStringHelper toStringHelper() { Objects.ToStringHelper toStringHelper = super.toStringHelper(); diff --git a/core/src/main/java/io/grpc/transport/AbstractStream.java b/core/src/main/java/io/grpc/transport/AbstractStream.java index 03a382456a..f9bcd75e7d 100644 --- a/core/src/main/java/io/grpc/transport/AbstractStream.java +++ b/core/src/main/java/io/grpc/transport/AbstractStream.java @@ -306,6 +306,8 @@ public abstract class AbstractStream implements Stream { return toStringHelper().toString(); } + // We support Guava 14 + @SuppressWarnings("deprecation") protected Objects.ToStringHelper toStringHelper() { return Objects.toStringHelper(this) .add("id", id()) diff --git a/core/src/test/java/io/grpc/ClientInterceptorsTest.java b/core/src/test/java/io/grpc/ClientInterceptorsTest.java index 1bd2a2654d..cfcee5d9fa 100644 --- a/core/src/test/java/io/grpc/ClientInterceptorsTest.java +++ b/core/src/test/java/io/grpc/ClientInterceptorsTest.java @@ -175,6 +175,7 @@ public class ClientInterceptorsTest { } }; Channel intercepted = ClientInterceptors.intercept(channel, interceptor); + @SuppressWarnings("unchecked") Call.Listener listener = mock(Call.Listener.class); Call interceptedCall = intercepted.newCall(method); // start() on the intercepted call will eventually reach the call created by the real channel @@ -209,11 +210,12 @@ public class ClientInterceptorsTest { } }; Channel intercepted = ClientInterceptors.intercept(channel, interceptor); + @SuppressWarnings("unchecked") Call.Listener listener = mock(Call.Listener.class); Call interceptedCall = intercepted.newCall(method); interceptedCall.start(listener, new Metadata.Headers()); // Capture the underlying call listener that will receive headers from the transport. - ArgumentCaptor captor = ArgumentCaptor.forClass(Call.Listener.class); + ArgumentCaptor> captor = ArgumentCaptor.forClass(null); verify(call).start(captor.capture(), Mockito.any()); Metadata.Headers inboundHeaders = new Metadata.Headers(); // Simulate that a headers arrives on the underlying call listener. diff --git a/integration-testing/src/main/java/io/grpc/testing/integration/TestServiceGrpc.java b/integration-testing/src/main/java/io/grpc/testing/integration/TestServiceGrpc.java index d016f7df07..8b2a0e7012 100644 --- a/integration-testing/src/main/java/io/grpc/testing/integration/TestServiceGrpc.java +++ b/integration-testing/src/main/java/io/grpc/testing/integration/TestServiceGrpc.java @@ -100,6 +100,7 @@ public class TestServiceGrpc { "grpc.testing.TestService", METHOD_HALF_DUPLEX_CALL); } + @SuppressWarnings("unchecked") private TestServiceServiceDescriptor( java.util.Map> methodMap) { emptyCall = (io.grpc.MethodDescriptor