Upgrade error_prone_annotations to 2.3.4

This commit is contained in:
Tomo Suzuki 2020-01-03 17:50:34 -05:00 committed by Eric Anderson
parent bcda439317
commit 75f6fd8f10
16 changed files with 52 additions and 22 deletions

View File

@ -44,7 +44,7 @@ repositories {
} }
dependencies { dependencies {
errorprone 'com.google.errorprone:error_prone_core:2.3.3' errorprone 'com.google.errorprone:error_prone_core:2.3.4'
errorproneJavac 'com.google.errorprone:javac:9+181-r4173-1' errorproneJavac 'com.google.errorprone:javac:9+181-r4173-1'
implementation 'io.grpc:grpc-core:1.27.0-SNAPSHOT' // CURRENT_GRPC_VERSION implementation 'io.grpc:grpc-core:1.27.0-SNAPSHOT' // CURRENT_GRPC_VERSION

View File

@ -113,7 +113,7 @@ subprojects {
libraries = [ libraries = [
android_annotations: "com.google.android:annotations:4.1.1.4", android_annotations: "com.google.android:annotations:4.1.1.4",
animalsniffer_annotations: "org.codehaus.mojo:animal-sniffer-annotations:1.18", animalsniffer_annotations: "org.codehaus.mojo:animal-sniffer-annotations:1.18",
errorprone: "com.google.errorprone:error_prone_annotations:2.3.3", errorprone: "com.google.errorprone:error_prone_annotations:2.3.4",
gson: "com.google.code.gson:gson:2.8.6", gson: "com.google.code.gson:gson:2.8.6",
guava: "com.google.guava:guava:${guavaVersion}", guava: "com.google.guava:guava:${guavaVersion}",
hpack: 'com.twitter:hpack:0.10.1', hpack: 'com.twitter:hpack:0.10.1',
@ -263,7 +263,7 @@ subprojects {
if (rootProject.properties.get('errorProne', true)) { if (rootProject.properties.get('errorProne', true)) {
dependencies { dependencies {
errorprone 'com.google.errorprone:error_prone_core:2.3.3' errorprone 'com.google.errorprone:error_prone_core:2.3.4'
errorproneJavac 'com.google.errorprone:javac:9+181-r4173-1' errorproneJavac 'com.google.errorprone:javac:9+181-r4173-1'
annotationProcessor 'com.google.guava:guava-beta-checker:1.0' annotationProcessor 'com.google.guava:guava-beta-checker:1.0'
@ -279,9 +279,17 @@ subprojects {
} }
} }
compileJava {
// This project targets Java 7 (no method references)
options.errorprone.check("UnnecessaryAnonymousClass", CheckSeverity.OFF)
// This project targets Java 7 (no time.Duration class)
options.errorprone.check("PreferJavaTimeOverload", CheckSeverity.OFF)
}
compileTestJava { compileTestJava {
// LinkedList doesn't hurt much in tests and has lots of usages // LinkedList doesn't hurt much in tests and has lots of usages
options.errorprone.check("JdkObsolete", CheckSeverity.OFF) options.errorprone.check("JdkObsolete", CheckSeverity.OFF)
options.errorprone.check("UnnecessaryAnonymousClass", CheckSeverity.OFF)
options.errorprone.check("PreferJavaTimeOverload", CheckSeverity.OFF)
} }
} }

View File

@ -16,7 +16,10 @@ dependencies {
compile project(':grpc-api'), compile project(':grpc-api'),
libraries.gson, libraries.gson,
libraries.android_annotations, libraries.android_annotations,
libraries.perfmark libraries.errorprone // prefer our version to perfmark's 2.3.3
compile (libraries.perfmark) {
exclude group: 'com.google.errorprone', module: 'error_prone_annotations'
}
compile (libraries.opencensus_api) { compile (libraries.opencensus_api) {
// prefer our own versions instead of opencensus-api's dependency // prefer our own versions instead of opencensus-api's dependency
exclude group: 'com.google.code.findbugs', module: 'jsr305' exclude group: 'com.google.code.findbugs', module: 'jsr305'
@ -56,3 +59,12 @@ animalsniffer {
sourceSets.test sourceSets.test
] ]
} }
import net.ltgt.gradle.errorprone.CheckSeverity
plugins.withId("java") {
compileJmhJava {
// This project targets Java 7 (no method references)
options.errorprone.check("UnnecessaryAnonymousClass", CheckSeverity.OFF)
}
}

View File

@ -3417,7 +3417,7 @@ public class ManagedChannelImplTest {
public void shutdown() {} public void shutdown() {}
} }
final class FakeNameResolverFactory extends NameResolver.Factory { final class FakeNameResolverFactory2 extends NameResolver.Factory {
FakeNameResolver resolver; FakeNameResolver resolver;
@Nullable @Nullable
@ -3432,7 +3432,7 @@ public class ManagedChannelImplTest {
} }
} }
FakeNameResolverFactory factory = new FakeNameResolverFactory(); FakeNameResolverFactory2 factory = new FakeNameResolverFactory2();
final class CustomBuilder extends AbstractManagedChannelImplBuilder<CustomBuilder> { final class CustomBuilder extends AbstractManagedChannelImplBuilder<CustomBuilder> {
CustomBuilder() { CustomBuilder() {

View File

@ -3437,7 +3437,7 @@ public class ManagedChannelImplTest2 {
public void shutdown() {} public void shutdown() {}
} }
final class FakeNameResolverFactory extends NameResolver.Factory { final class FakeNameResolverFactory2 extends NameResolver.Factory {
FakeNameResolver resolver; FakeNameResolver resolver;
@Nullable @Nullable
@ -3452,7 +3452,7 @@ public class ManagedChannelImplTest2 {
} }
} }
FakeNameResolverFactory factory = new FakeNameResolverFactory(); FakeNameResolverFactory2 factory = new FakeNameResolverFactory2();
final class CustomBuilder extends AbstractManagedChannelImplBuilder<CustomBuilder> { final class CustomBuilder extends AbstractManagedChannelImplBuilder<CustomBuilder> {
CustomBuilder() { CustomBuilder() {

View File

@ -51,7 +51,7 @@ android {
} }
dependencies { dependencies {
errorprone 'com.google.errorprone:error_prone_core:2.3.3' errorprone 'com.google.errorprone:error_prone_core:2.3.4'
errorproneJavac 'com.google.errorprone:javac:9+181-r4173-1' errorproneJavac 'com.google.errorprone:javac:9+181-r4173-1'
implementation 'io.grpc:grpc-core:1.27.0-SNAPSHOT' // CURRENT_GRPC_VERSION implementation 'io.grpc:grpc-core:1.27.0-SNAPSHOT' // CURRENT_GRPC_VERSION

View File

@ -94,6 +94,7 @@ public final class CronetClientStreamTest {
} }
@Override @Override
@SuppressWarnings("GuardedBy")
public void run() { public void run() {
assertTrue(stream != null); assertTrue(stream != null);
stream.transportState().start(factory); stream.transportState().start(factory);

View File

@ -65,7 +65,7 @@
<dependency> <dependency>
<groupId>com.google.errorprone</groupId> <groupId>com.google.errorprone</groupId>
<artifactId>error_prone_annotations</artifactId> <artifactId>error_prone_annotations</artifactId>
<version>2.3.3</version> <!-- prefer to use 2.3.3 or later --> <version>2.3.4</version> <!-- prefer to use 2.3.3 or later -->
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>

View File

@ -37,6 +37,7 @@ public class Util {
= Metadata.Key.of("x-grpc-test-echo-trailing-bin", Metadata.BINARY_BYTE_MARSHALLER); = Metadata.Key.of("x-grpc-test-echo-trailing-bin", Metadata.BINARY_BYTE_MARSHALLER);
/** Assert that two messages are equal, producing a useful message if not. */ /** Assert that two messages are equal, producing a useful message if not. */
@SuppressWarnings("LiteProtoToString")
public static void assertEquals(MessageLite expected, MessageLite actual) { public static void assertEquals(MessageLite expected, MessageLite actual) {
if (expected == null || actual == null) { if (expected == null || actual == null) {
Assert.assertEquals(expected, actual); Assert.assertEquals(expected, actual);

View File

@ -12,6 +12,7 @@ java_library(
"//api", "//api",
"//core:internal", "//core:internal",
"@com_google_code_findbugs_jsr305//jar", "@com_google_code_findbugs_jsr305//jar",
"@com_google_errorprone_error_prone_annotations//jar",
"@com_google_guava_guava//jar", "@com_google_guava_guava//jar",
"@com_google_j2objc_j2objc_annotations//jar", "@com_google_j2objc_j2objc_annotations//jar",
"@com_squareup_okhttp_okhttp//jar", "@com_squareup_okhttp_okhttp//jar",

View File

@ -127,6 +127,7 @@ public class OkHttpClientStreamTest {
} }
@Test @Test
@SuppressWarnings("GuardedBy")
public void cancel_started() { public void cancel_started() {
stream.start(new BaseClientStreamListener()); stream.start(new BaseClientStreamListener());
stream.transportState().start(1234); stream.transportState().start(1234);
@ -145,6 +146,7 @@ public class OkHttpClientStreamTest {
} }
@Test @Test
@SuppressWarnings("GuardedBy")
public void start_alreadyCancelled() { public void start_alreadyCancelled() {
stream.start(new BaseClientStreamListener()); stream.start(new BaseClientStreamListener());
stream.cancel(Status.CANCELLED); stream.cancel(Status.CANCELLED);
@ -155,6 +157,7 @@ public class OkHttpClientStreamTest {
} }
@Test @Test
@SuppressWarnings("GuardedBy")
public void start_userAgentRemoved() throws IOException { public void start_userAgentRemoved() throws IOException {
Metadata metaData = new Metadata(); Metadata metaData = new Metadata();
metaData.put(GrpcUtil.USER_AGENT_KEY, "misbehaving-application"); metaData.put(GrpcUtil.USER_AGENT_KEY, "misbehaving-application");
@ -171,6 +174,7 @@ public class OkHttpClientStreamTest {
} }
@Test @Test
@SuppressWarnings("GuardedBy")
public void start_headerFieldOrder() throws IOException { public void start_headerFieldOrder() throws IOException {
Metadata metaData = new Metadata(); Metadata metaData = new Metadata();
metaData.put(GrpcUtil.USER_AGENT_KEY, "misbehaving-application"); metaData.put(GrpcUtil.USER_AGENT_KEY, "misbehaving-application");
@ -194,6 +198,7 @@ public class OkHttpClientStreamTest {
} }
@Test @Test
@SuppressWarnings("GuardedBy")
public void start_headerPlaintext() throws IOException { public void start_headerPlaintext() throws IOException {
Metadata metaData = new Metadata(); Metadata metaData = new Metadata();
metaData.put(GrpcUtil.USER_AGENT_KEY, "misbehaving-application"); metaData.put(GrpcUtil.USER_AGENT_KEY, "misbehaving-application");
@ -218,6 +223,7 @@ public class OkHttpClientStreamTest {
} }
@Test @Test
@SuppressWarnings("GuardedBy")
public void getUnaryRequest() throws IOException { public void getUnaryRequest() throws IOException {
MethodDescriptor<?, ?> getMethod = MethodDescriptor.<Void, Void>newBuilder() MethodDescriptor<?, ?> getMethod = MethodDescriptor.<Void, Void>newBuilder()
.setType(MethodDescriptor.MethodType.UNARY) .setType(MethodDescriptor.MethodType.UNARY)

View File

@ -2127,7 +2127,7 @@ public class OkHttpClientTransportTest {
// The wait is safe; nextFrame is called in a loop and can have spurious wakeups // The wait is safe; nextFrame is called in a loop and can have spurious wakeups
@SuppressWarnings("WaitNotInLoop") @SuppressWarnings("WaitNotInLoop")
@Override @Override
public boolean nextFrame(Handler handler) throws IOException { public boolean nextFrame(FrameReader.Handler handler) throws IOException {
Result result; Result result;
try { try {
result = nextResults.take(); result = nextResults.take();

View File

@ -19,6 +19,7 @@
package io.grpc.okhttp.internal.framed; package io.grpc.okhttp.internal.framed;
import com.google.errorprone.annotations.FormatMethod;
import io.grpc.okhttp.internal.Protocol; import io.grpc.okhttp.internal.Protocol;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
@ -361,7 +362,7 @@ public final class Http2 implements Variant {
throws IOException { throws IOException {
if (length != 4) throw ioException("TYPE_WINDOW_UPDATE length !=4: %s", length); if (length != 4) throw ioException("TYPE_WINDOW_UPDATE length !=4: %s", length);
long increment = (source.readInt() & 0x7fffffffL); long increment = (source.readInt() & 0x7fffffffL);
if (increment == 0) throw ioException("windowSizeIncrement was 0", increment); if (increment == 0) throw ioException("windowSizeIncrement was 0");
handler.windowUpdate(streamId, increment); handler.windowUpdate(streamId, increment);
} }
@ -586,10 +587,12 @@ public final class Http2 implements Variant {
} }
} }
@FormatMethod
private static IllegalArgumentException illegalArgument(String message, Object... args) { private static IllegalArgumentException illegalArgument(String message, Object... args) {
throw new IllegalArgumentException(format(message, args)); throw new IllegalArgumentException(format(message, args));
} }
@FormatMethod
private static IOException ioException(String message, Object... args) throws IOException { private static IOException ioException(String message, Object... args) throws IOException {
throw new IOException(format(message, args)); throw new IOException(format(message, args));
} }

View File

@ -17,7 +17,7 @@ IO_GRPC_GRPC_JAVA_ARTIFACTS = [
"com.google.auth:google-auth-library-oauth2-http:0.19.0", "com.google.auth:google-auth-library-oauth2-http:0.19.0",
"com.google.code.findbugs:jsr305:3.0.2", "com.google.code.findbugs:jsr305:3.0.2",
"com.google.code.gson:gson:jar:2.8.6", "com.google.code.gson:gson:jar:2.8.6",
"com.google.errorprone:error_prone_annotations:2.3.3", "com.google.errorprone:error_prone_annotations:2.3.4",
"com.google.guava:failureaccess:1.0.1", "com.google.guava:failureaccess:1.0.1",
"com.google.guava:guava:28.1-android", "com.google.guava:guava:28.1-android",
"com.google.j2objc:j2objc-annotations:1.3", "com.google.j2objc:j2objc-annotations:1.3",
@ -226,9 +226,9 @@ def com_google_code_gson_gson():
def com_google_errorprone_error_prone_annotations(): def com_google_errorprone_error_prone_annotations():
jvm_maven_import_external( jvm_maven_import_external(
name = "com_google_errorprone_error_prone_annotations", name = "com_google_errorprone_error_prone_annotations",
artifact = "com.google.errorprone:error_prone_annotations:2.3.3", artifact = "com.google.errorprone:error_prone_annotations:2.3.4",
server_urls = ["https://repo.maven.apache.org/maven2/"], server_urls = ["https://repo.maven.apache.org/maven2/"],
artifact_sha256 = "ec59f1b702d9afc09e8c3929f5c42777dec623a6ea2731ac694332c7d7680f5a", artifact_sha256 = "baf7d6ea97ce606c53e11b6854ba5f2ce7ef5c24dddf0afa18d1260bd25b002c",
licenses = ["notice"], # Apache 2.0 licenses = ["notice"], # Apache 2.0
) )

View File

@ -46,7 +46,6 @@ import io.grpc.Metadata;
import io.grpc.MethodDescriptor; import io.grpc.MethodDescriptor;
import io.grpc.MethodDescriptor.Marshaller; import io.grpc.MethodDescriptor.Marshaller;
import io.grpc.ServerCall; import io.grpc.ServerCall;
import io.grpc.ServerCall.Listener;
import io.grpc.ServerCallHandler; import io.grpc.ServerCallHandler;
import io.grpc.ServerInterceptor; import io.grpc.ServerInterceptor;
import io.grpc.Status; import io.grpc.Status;
@ -408,7 +407,7 @@ final class BinlogHelper {
return new SimpleForwardingClientCall<ReqT, RespT>(next.newCall(method, callOptions)) { return new SimpleForwardingClientCall<ReqT, RespT>(next.newCall(method, callOptions)) {
@Override @Override
public void start(final Listener<RespT> responseListener, Metadata headers) { public void start(final ClientCall.Listener<RespT> responseListener, Metadata headers) {
final Duration timeout = deadline == null ? null final Duration timeout = deadline == null ? null
: Durations.fromNanos(deadline.timeRemaining(TimeUnit.NANOSECONDS)); : Durations.fromNanos(deadline.timeRemaining(TimeUnit.NANOSECONDS));
writer.logClientHeader( writer.logClientHeader(
@ -500,7 +499,7 @@ final class BinlogHelper {
public ServerInterceptor getServerInterceptor(final long callId) { public ServerInterceptor getServerInterceptor(final long callId) {
return new ServerInterceptor() { return new ServerInterceptor() {
@Override @Override
public <ReqT, RespT> Listener<ReqT> interceptCall( public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(
final ServerCall<ReqT, RespT> call, final ServerCall<ReqT, RespT> call,
Metadata headers, Metadata headers,
ServerCallHandler<ReqT, RespT> next) { ServerCallHandler<ReqT, RespT> next) {

View File

@ -36,7 +36,6 @@ import io.grpc.MethodDescriptor;
import io.grpc.MethodDescriptor.Marshaller; import io.grpc.MethodDescriptor.Marshaller;
import io.grpc.MethodDescriptor.MethodType; import io.grpc.MethodDescriptor.MethodType;
import io.grpc.ServerCall; import io.grpc.ServerCall;
import io.grpc.ServerCall.Listener;
import io.grpc.ServerCallHandler; import io.grpc.ServerCallHandler;
import io.grpc.ServerInterceptor; import io.grpc.ServerInterceptor;
import io.grpc.ServerMethodDefinition; import io.grpc.ServerMethodDefinition;
@ -127,7 +126,7 @@ public class BinaryLogProviderTest {
MethodDescriptor<RequestT, ResponseT> methodDescriptor, CallOptions callOptions) { MethodDescriptor<RequestT, ResponseT> methodDescriptor, CallOptions callOptions) {
return new NoopClientCall<RequestT, ResponseT>() { return new NoopClientCall<RequestT, ResponseT>() {
@Override @Override
public void start(Listener<ResponseT> responseListener, Metadata headers) { public void start(ClientCall.Listener<ResponseT> responseListener, Metadata headers) {
listener.set(responseListener); listener.set(responseListener);
} }
@ -211,7 +210,7 @@ public class BinaryLogProviderTest {
method, method,
new ServerCallHandler<String, Integer>() { new ServerCallHandler<String, Integer>() {
@Override @Override
public Listener<String> startCall( public ServerCall.Listener<String> startCall(
ServerCall<String, Integer> call, Metadata headers) { ServerCall<String, Integer> call, Metadata headers) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@ -310,7 +309,7 @@ public class BinaryLogProviderTest {
assertSame(BinaryLogProvider.BYTEARRAY_MARSHALLER, method.getResponseMarshaller()); assertSame(BinaryLogProvider.BYTEARRAY_MARSHALLER, method.getResponseMarshaller());
return new SimpleForwardingClientCall<ReqT, RespT>(next.newCall(method, callOptions)) { return new SimpleForwardingClientCall<ReqT, RespT>(next.newCall(method, callOptions)) {
@Override @Override
public void start(Listener<RespT> responseListener, Metadata headers) { public void start(ClientCall.Listener<RespT> responseListener, Metadata headers) {
super.start( super.start(
new SimpleForwardingClientCallListener<RespT>(responseListener) { new SimpleForwardingClientCallListener<RespT>(responseListener) {
@Override @Override