From 7657523b28624016cf3ca642c02e713da5f33ca3 Mon Sep 17 00:00:00 2001 From: Carl Mastrangelo Date: Wed, 5 Jun 2019 15:28:43 -0700 Subject: [PATCH] all: update to error prone 2.3.3 --- .../alts/internal/AltsHandshakerClient.java | 2 +- .../internal/AltsProtocolNegotiatorTest.java | 6 ++--- android/build.gradle | 2 +- api/build.gradle | 2 +- .../java/io/grpc/ServiceProvidersTest.java | 24 +++++++++---------- build.gradle | 2 +- .../src/test/java/io/grpc/ContextTest.java | 2 +- .../io/grpc/internal/InternalSubchannel.java | 2 -- .../io/grpc/internal/ManagedChannelImpl.java | 1 + .../internal/ManagedChannelServiceConfig.java | 1 + .../ManagedChannelOrphanWrapperTest.java | 6 +++++ .../NettyClientInteropServlet.java | 4 ++-- .../main/java/io/grpc/netty/JettyTlsUtil.java | 2 ++ .../io/grpc/okhttp/internal/CipherSuite.java | 1 + .../okhttp/internal/OkHostnameVerifier.java | 2 ++ .../io/grpc/okhttp/internal/framed/Http2.java | 12 ++++++---- protobuf-lite/build.gradle | 2 +- repositories.bzl | 4 ++-- .../java/io/grpc/stub/ServerCallsTest.java | 4 ---- 19 files changed, 44 insertions(+), 37 deletions(-) diff --git a/alts/src/main/java/io/grpc/alts/internal/AltsHandshakerClient.java b/alts/src/main/java/io/grpc/alts/internal/AltsHandshakerClient.java index 26dcde3873..dd2d287b56 100644 --- a/alts/src/main/java/io/grpc/alts/internal/AltsHandshakerClient.java +++ b/alts/src/main/java/io/grpc/alts/internal/AltsHandshakerClient.java @@ -136,7 +136,7 @@ class AltsHandshakerClient { throw new IllegalStateException("Could not get enough key data from the handshake."); } byte[] key = new byte[KEY_LENGTH]; - result.getKeyData().copyTo(key, 0, 0, KEY_LENGTH); + result.getKeyData().copyTo(key, 0); return key; } diff --git a/alts/src/test/java/io/grpc/alts/internal/AltsProtocolNegotiatorTest.java b/alts/src/test/java/io/grpc/alts/internal/AltsProtocolNegotiatorTest.java index 7d8e637ba8..76b4267445 100644 --- a/alts/src/test/java/io/grpc/alts/internal/AltsProtocolNegotiatorTest.java +++ b/alts/src/test/java/io/grpc/alts/internal/AltsProtocolNegotiatorTest.java @@ -27,7 +27,6 @@ import io.grpc.Attributes; import io.grpc.Channel; import io.grpc.Grpc; import io.grpc.InternalChannelz; -import io.grpc.InternalChannelz.Security; import io.grpc.ManagedChannel; import io.grpc.SecurityLevel; import io.grpc.alts.internal.AltsProtocolNegotiator.LazyChannel; @@ -396,7 +395,6 @@ public class AltsProtocolNegotiatorTest { private final class CapturingGrpcHttp2ConnectionHandler extends GrpcHttp2ConnectionHandler { private Attributes attrs; - private Security securityInfo; private CapturingGrpcHttp2ConnectionHandler( Http2ConnectionDecoder decoder, @@ -407,11 +405,11 @@ public class AltsProtocolNegotiatorTest { @Override public void handleProtocolNegotiationCompleted( - Attributes attrs, InternalChannelz.Security securityInfo) { + Attributes attrs, + @SuppressWarnings("UnusedVariable") InternalChannelz.Security securityInfo) { // If we are added to the pipeline, we need to remove ourselves. The HTTP2 handler channel.pipeline().remove(this); this.attrs = attrs; - this.securityInfo = securityInfo; } } diff --git a/android/build.gradle b/android/build.gradle index cdc83539a4..62b7649692 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -43,7 +43,7 @@ repositories { } dependencies { - errorprone 'com.google.errorprone:error_prone_core:2.3.2' + errorprone 'com.google.errorprone:error_prone_core:2.3.3' errorproneJavac 'com.google.errorprone:javac:9+181-r4173-1' implementation 'io.grpc:grpc-core:1.22.0-SNAPSHOT' // CURRENT_GRPC_VERSION diff --git a/api/build.gradle b/api/build.gradle index a7749687ad..98a4d5b19b 100644 --- a/api/build.gradle +++ b/api/build.gradle @@ -6,7 +6,7 @@ dependencies { libraries.jsr305, libraries.animalsniffer_annotations compile (libraries.guava) { - // prefer 2.3.2 from libraries instead of 2.1.3 + // prefer 2.3.3 from libraries instead of 2.1.3 exclude group: 'com.google.errorprone', module: 'error_prone_annotations' // prefer 3.0.2 from libraries instead of 3.0.1 exclude group: 'com.google.code.findbugs', module: 'jsr305' diff --git a/api/src/test/java/io/grpc/ServiceProvidersTest.java b/api/src/test/java/io/grpc/ServiceProvidersTest.java index d069501642..4bbfe2117b 100644 --- a/api/src/test/java/io/grpc/ServiceProvidersTest.java +++ b/api/src/test/java/io/grpc/ServiceProvidersTest.java @@ -125,7 +125,7 @@ public class ServiceProvidersTest { ClassLoader cl = new ReplacingClassLoader(getClass().getClassLoader(), serviceFile, "io/grpc/ServiceProvidersTestAbstractProvider-unknownClassProvider.txt"); try { - ServiceProvidersTestAbstractProvider ignored = ServiceProviders.load( + ServiceProviders.load( ServiceProvidersTestAbstractProvider.class, NO_HARDCODED, cl, ACCESSOR); fail("Exception expected"); } catch (ServiceConfigurationError e) { @@ -140,7 +140,7 @@ public class ServiceProvidersTest { try { // Even though there is a working provider, if any providers fail then we should fail // completely to avoid returning something unexpected. - ServiceProvidersTestAbstractProvider ignored = ServiceProviders.load( + ServiceProviders.load( ServiceProvidersTestAbstractProvider.class, NO_HARDCODED, cl, ACCESSOR); fail("Expected exception"); } catch (ServiceConfigurationError expected) { @@ -154,7 +154,7 @@ public class ServiceProvidersTest { "io/grpc/ServiceProvidersTestAbstractProvider-failAtPriorityProvider.txt"); try { // The exception should be surfaced to the caller - ServiceProvidersTestAbstractProvider ignored = ServiceProviders.load( + ServiceProviders.load( ServiceProvidersTestAbstractProvider.class, NO_HARDCODED, cl, ACCESSOR); fail("Expected exception"); } catch (FailAtPriorityProvider.PriorityException expected) { @@ -168,7 +168,7 @@ public class ServiceProvidersTest { "io/grpc/ServiceProvidersTestAbstractProvider-failAtAvailableProvider.txt"); try { // The exception should be surfaced to the caller - ServiceProvidersTestAbstractProvider ignored = ServiceProviders.load( + ServiceProviders.load( ServiceProvidersTestAbstractProvider.class, NO_HARDCODED, cl, ACCESSOR); fail("Expected exception"); } catch (FailAtAvailableProvider.AvailableException expected) { @@ -193,10 +193,9 @@ public class ServiceProvidersTest { @Test public void getCandidatesViaHardCoded_failAtInit() throws Exception { try { - Iterable ignored = - ServiceProviders.getCandidatesViaHardCoded( - ServiceProvidersTestAbstractProvider.class, - Collections.>singletonList(FailAtInitProvider.class)); + ServiceProviders.getCandidatesViaHardCoded( + ServiceProvidersTestAbstractProvider.class, + Collections.>singletonList(FailAtInitProvider.class)); fail("Expected exception"); } catch (ServiceConfigurationError expected) { // noop @@ -206,10 +205,9 @@ public class ServiceProvidersTest { @Test public void getCandidatesViaHardCoded_failAtInit_moreCandidates() throws Exception { try { - Iterable ignored = - ServiceProviders.getCandidatesViaHardCoded( - ServiceProvidersTestAbstractProvider.class, - ImmutableList.>of(FailAtInitProvider.class, Available0Provider.class)); + ServiceProviders.getCandidatesViaHardCoded( + ServiceProvidersTestAbstractProvider.class, + ImmutableList.>of(FailAtInitProvider.class, Available0Provider.class)); fail("Expected exception"); } catch (ServiceConfigurationError expected) { // noop @@ -221,7 +219,7 @@ public class ServiceProvidersTest { class PrivateClass {} try { - ServiceProvidersTestAbstractProvider ignored = ServiceProviders.create( + ServiceProviders.create( ServiceProvidersTestAbstractProvider.class, PrivateClass.class); fail("Expected exception"); } catch (ServiceConfigurationError expected) { diff --git a/build.gradle b/build.gradle index b1e61fd347..bd7ea60b3f 100644 --- a/build.gradle +++ b/build.gradle @@ -31,7 +31,7 @@ subprojects { apply plugin: "net.ltgt.errorprone" if (rootProject.properties.get('errorProne', true)) { dependencies { - errorprone 'com.google.errorprone:error_prone_core:2.3.2' + errorprone 'com.google.errorprone:error_prone_core:2.3.3' errorproneJavac 'com.google.errorprone:javac:9+181-r4173-1' annotationProcessor 'com.google.guava:guava-beta-checker:1.0' diff --git a/context/src/test/java/io/grpc/ContextTest.java b/context/src/test/java/io/grpc/ContextTest.java index 8feef85c1a..66b56372e6 100644 --- a/context/src/test/java/io/grpc/ContextTest.java +++ b/context/src/test/java/io/grpc/ContextTest.java @@ -967,7 +967,7 @@ public class ContextTest { assertNull(logRef.get()); ctx = ctx.fork(); } - ctx = ctx.fork(); + ctx.fork(); assertNotNull(logRef.get()); assertNotNull(logRef.get().getThrown()); assertEquals(Level.SEVERE, logRef.get().getLevel()); diff --git a/core/src/main/java/io/grpc/internal/InternalSubchannel.java b/core/src/main/java/io/grpc/internal/InternalSubchannel.java index f1a37b87af..2983957113 100644 --- a/core/src/main/java/io/grpc/internal/InternalSubchannel.java +++ b/core/src/main/java/io/grpc/internal/InternalSubchannel.java @@ -55,7 +55,6 @@ import java.util.Collections; import java.util.List; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; -import java.util.logging.Logger; import javax.annotation.Nullable; import javax.annotation.concurrent.ThreadSafe; @@ -64,7 +63,6 @@ import javax.annotation.concurrent.ThreadSafe; */ @ThreadSafe final class InternalSubchannel implements InternalInstrumented, TransportProvider { - private static final Logger log = Logger.getLogger(InternalSubchannel.class.getName()); private final InternalLogId logId; private final String authority; diff --git a/core/src/main/java/io/grpc/internal/ManagedChannelImpl.java b/core/src/main/java/io/grpc/internal/ManagedChannelImpl.java index d2d3a9ca3f..510e6a5cc9 100644 --- a/core/src/main/java/io/grpc/internal/ManagedChannelImpl.java +++ b/core/src/main/java/io/grpc/internal/ManagedChannelImpl.java @@ -254,6 +254,7 @@ final class ManagedChannelImpl extends ManagedChannel implements // Must be mutated and read from constructor or syncContext // See service config error handling spec for reference. // TODO(notcarl): check this value when error in service config resolution + @SuppressWarnings("UnusedVariable") private boolean waitingForServiceConfig = true; private final boolean lookUpServiceConfig; diff --git a/core/src/main/java/io/grpc/internal/ManagedChannelServiceConfig.java b/core/src/main/java/io/grpc/internal/ManagedChannelServiceConfig.java index 2f7f6d874c..b6f7ae9f5c 100644 --- a/core/src/main/java/io/grpc/internal/ManagedChannelServiceConfig.java +++ b/core/src/main/java/io/grpc/internal/ManagedChannelServiceConfig.java @@ -45,6 +45,7 @@ final class ManagedChannelServiceConfig { private final Map serviceMap; // TODO(notcarl/zdapeng): use retryThrottling here @Nullable + @SuppressWarnings("unused") private final Throttle retryThrottling; @Nullable private final Object loadBalancingConfig; diff --git a/core/src/test/java/io/grpc/internal/ManagedChannelOrphanWrapperTest.java b/core/src/test/java/io/grpc/internal/ManagedChannelOrphanWrapperTest.java index 17c3f8cdc3..5ae97c6921 100644 --- a/core/src/test/java/io/grpc/internal/ManagedChannelOrphanWrapperTest.java +++ b/core/src/test/java/io/grpc/internal/ManagedChannelOrphanWrapperTest.java @@ -54,6 +54,7 @@ public final class ManagedChannelOrphanWrapperTest { new ConcurrentHashMap<>(); assertEquals(0, refs.size()); + @SuppressWarnings("UnusedVariable") ManagedChannelOrphanWrapper channel = new ManagedChannelOrphanWrapper(mc, refqueue, refs); assertEquals(1, refs.size()); @@ -106,8 +107,11 @@ public final class ManagedChannelOrphanWrapperTest { new ReferenceQueue<>(); ConcurrentMap refs = new ConcurrentHashMap<>(); + @SuppressWarnings("UnusedVariable") ApplicationWithChannelRef app = new ApplicationWithChannelRef(); + @SuppressWarnings("UnusedVariable") ChannelWithApplicationRef channelImpl = new ChannelWithApplicationRef(); + @SuppressWarnings("UnusedVariable") ManagedChannelOrphanWrapper channel = new ManagedChannelOrphanWrapper(channelImpl, refqueue, refs); app.channel = channel; @@ -164,10 +168,12 @@ public final class ManagedChannelOrphanWrapperTest { } private static final class ApplicationWithChannelRef { + @SuppressWarnings("UnusedVariable") private ManagedChannel channel; } private static final class ChannelWithApplicationRef extends TestManagedChannel { + @SuppressWarnings("UnusedVariable") private ApplicationWithChannelRef application; } } diff --git a/gae-interop-testing/gae-jdk8/src/main/java/io/grpc/testing/integration/NettyClientInteropServlet.java b/gae-interop-testing/gae-jdk8/src/main/java/io/grpc/testing/integration/NettyClientInteropServlet.java index b8220cf444..a6845dc068 100644 --- a/gae-interop-testing/gae-jdk8/src/main/java/io/grpc/testing/integration/NettyClientInteropServlet.java +++ b/gae-interop-testing/gae-jdk8/src/main/java/io/grpc/testing/integration/NettyClientInteropServlet.java @@ -80,7 +80,7 @@ public final class NettyClientInteropServlet extends HttpServlet { LogEntryRecorder handler = new LogEntryRecorder(); Logger.getLogger("").addHandler(handler); try { - doGetHelper(req, resp); + doGetHelper(resp); } finally { Logger.getLogger("").removeHandler(handler); } @@ -89,7 +89,7 @@ public final class NettyClientInteropServlet extends HttpServlet { .append(handler.getLogOutput()); } - private void doGetHelper(HttpServletRequest req, HttpServletResponse resp) throws IOException { + private void doGetHelper(HttpServletResponse resp) throws IOException { resp.setContentType("text/plain"); PrintWriter writer = resp.getWriter(); writer.println("Test invoked at: "); diff --git a/netty/src/main/java/io/grpc/netty/JettyTlsUtil.java b/netty/src/main/java/io/grpc/netty/JettyTlsUtil.java index ef31756f57..392aaf8d3e 100644 --- a/netty/src/main/java/io/grpc/netty/JettyTlsUtil.java +++ b/netty/src/main/java/io/grpc/netty/JettyTlsUtil.java @@ -72,6 +72,7 @@ final class JettyTlsUtil { static synchronized Throwable getJettyAlpnUnavailabilityCause() { // This case should be unlikely if (jettyAlpnUnavailabilityCause == null) { + @SuppressWarnings("UnusedVariable") boolean discard = isJettyAlpnConfigured(); } return jettyAlpnUnavailabilityCause; @@ -93,6 +94,7 @@ final class JettyTlsUtil { static synchronized Throwable getJettyNpnUnavailabilityCause() { // This case should be unlikely if (jettyNpnUnavailabilityCause == null) { + @SuppressWarnings("UnusedVariable") boolean discard = isJettyNpnConfigured(); } return jettyNpnUnavailabilityCause; diff --git a/okhttp/third_party/okhttp/main/java/io/grpc/okhttp/internal/CipherSuite.java b/okhttp/third_party/okhttp/main/java/io/grpc/okhttp/internal/CipherSuite.java index bc2a9b7f0f..70fa796f24 100644 --- a/okhttp/third_party/okhttp/main/java/io/grpc/okhttp/internal/CipherSuite.java +++ b/okhttp/third_party/okhttp/main/java/io/grpc/okhttp/internal/CipherSuite.java @@ -366,6 +366,7 @@ public enum CipherSuite { * @param sinceJavaVersion the first major Java release supporting this cipher suite. * @param sinceAndroidVersion the first Android SDK version supporting this cipher suite. */ + @SuppressWarnings("UnusedVariable") private CipherSuite( String javaName, int value, int rfc, int sinceJavaVersion, int sinceAndroidVersion) { this.javaName = javaName; diff --git a/okhttp/third_party/okhttp/main/java/io/grpc/okhttp/internal/OkHostnameVerifier.java b/okhttp/third_party/okhttp/main/java/io/grpc/okhttp/internal/OkHostnameVerifier.java index f65a433bc4..34bb56ee2d 100644 --- a/okhttp/third_party/okhttp/main/java/io/grpc/okhttp/internal/OkHostnameVerifier.java +++ b/okhttp/third_party/okhttp/main/java/io/grpc/okhttp/internal/OkHostnameVerifier.java @@ -120,6 +120,7 @@ public final class OkHostnameVerifier implements HostnameVerifier { return false; } + @SuppressWarnings("MixedMutabilityReturnType") public static List allSubjectAltNames(X509Certificate certificate) { List altIpaNames = getSubjectAltNames(certificate, ALT_IPA_NAME); List altDnsNames = getSubjectAltNames(certificate, ALT_DNS_NAME); @@ -129,6 +130,7 @@ public final class OkHostnameVerifier implements HostnameVerifier { return result; } + @SuppressWarnings("MixedMutabilityReturnType") private static List getSubjectAltNames(X509Certificate certificate, int type) { List result = new ArrayList<>(); try { diff --git a/okhttp/third_party/okhttp/main/java/io/grpc/okhttp/internal/framed/Http2.java b/okhttp/third_party/okhttp/main/java/io/grpc/okhttp/internal/framed/Http2.java index 20eed3c3b3..67ba33a68b 100644 --- a/okhttp/third_party/okhttp/main/java/io/grpc/okhttp/internal/framed/Http2.java +++ b/okhttp/third_party/okhttp/main/java/io/grpc/okhttp/internal/framed/Http2.java @@ -234,7 +234,8 @@ public final class Http2 implements Variant { source.skip(padding); } - private void readPriority(Handler handler, int length, byte flags, int streamId) + private void readPriority( + Handler handler, int length, @SuppressWarnings("UnusedVariable") byte flags, int streamId) throws IOException { if (length != 5) throw ioException("TYPE_PRIORITY length: %d != 5", length); if (streamId == 0) throw ioException("TYPE_PRIORITY streamId == 0"); @@ -249,7 +250,8 @@ public final class Http2 implements Variant { handler.priority(streamId, streamDependency, weight, exclusive); } - private void readRstStream(Handler handler, int length, byte flags, int streamId) + private void readRstStream( + Handler handler, int length, @SuppressWarnings("UnusedVariable") byte flags, int streamId) throws IOException { if (length != 4) throw ioException("TYPE_RST_STREAM length: %d != 4", length); if (streamId == 0) throw ioException("TYPE_RST_STREAM streamId == 0"); @@ -335,7 +337,8 @@ public final class Http2 implements Variant { handler.ping(ack, payload1, payload2); } - private void readGoAway(Handler handler, int length, byte flags, int streamId) + private void readGoAway( + Handler handler, int length, @SuppressWarnings("UnusedVariable") byte flags, int streamId) throws IOException { if (length < 8) throw ioException("TYPE_GOAWAY length < 8: %s", length); if (streamId != 0) throw ioException("TYPE_GOAWAY streamId != 0"); @@ -353,7 +356,8 @@ public final class Http2 implements Variant { handler.goAway(lastStreamId, errorCode, debugData); } - private void readWindowUpdate(Handler handler, int length, byte flags, int streamId) + private void readWindowUpdate( + Handler handler, int length, @SuppressWarnings("UnusedVariable") byte flags, int streamId) throws IOException { if (length != 4) throw ioException("TYPE_WINDOW_UPDATE length !=4: %s", length); long increment = (source.readInt() & 0x7fffffffL); diff --git a/protobuf-lite/build.gradle b/protobuf-lite/build.gradle index 6503c2707c..74f75c6aa8 100644 --- a/protobuf-lite/build.gradle +++ b/protobuf-lite/build.gradle @@ -15,7 +15,7 @@ dependencies { compile project(':grpc-api'), libraries.protobuf_lite compile (libraries.guava) { - // prefer 2.3.2 from libraries instead of 2.1.3 + // prefer 2.3.3 from libraries instead of 2.1.3 exclude group: 'com.google.errorprone', module: 'error_prone_annotations' // prefer 3.0.2 from libraries instead of 3.0.1 exclude group: 'com.google.code.findbugs', module: 'jsr305' diff --git a/repositories.bzl b/repositories.bzl index ddcc9c3f83..4fd98cec56 100644 --- a/repositories.bzl +++ b/repositories.bzl @@ -196,9 +196,9 @@ def com_google_code_gson(): def com_google_errorprone_error_prone_annotations(): jvm_maven_import_external( name = "com_google_errorprone_error_prone_annotations", - artifact = "com.google.errorprone:error_prone_annotations:2.3.2", + artifact = "com.google.errorprone:error_prone_annotations:2.3.3", server_urls = ["http://central.maven.org/maven2"], - artifact_sha256 = "357cd6cfb067c969226c442451502aee13800a24e950fdfde77bcdb4565a668d", + artifact_sha256 = "ec59f1b702d9afc09e8c3929f5c42777dec623a6ea2731ac694332c7d7680f5a", licenses = ["notice"], # Apache 2.0 ) diff --git a/stub/src/test/java/io/grpc/stub/ServerCallsTest.java b/stub/src/test/java/io/grpc/stub/ServerCallsTest.java index 973b2a7d02..77e24fe522 100644 --- a/stub/src/test/java/io/grpc/stub/ServerCallsTest.java +++ b/stub/src/test/java/io/grpc/stub/ServerCallsTest.java @@ -532,8 +532,6 @@ public class ServerCallsTest { private final MethodDescriptor methodDescriptor; private final List requestCalls = new ArrayList<>(); private final List responses = new ArrayList<>(); - private Metadata headers; - private Metadata trailers; private Status status; private boolean isCancelled; private boolean isReady; @@ -549,7 +547,6 @@ public class ServerCallsTest { @Override public void sendHeaders(Metadata headers) { - this.headers = headers; } @Override @@ -560,7 +557,6 @@ public class ServerCallsTest { @Override public void close(Status status, Metadata trailers) { this.status = status; - this.trailers = trailers; } @Override