Skip to content

Commit

Permalink
Upgrade error_prone_annotations to 2.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
suztomo authored and ejona86 committed Jan 3, 2020
1 parent bcda439 commit 75f6fd8
Show file tree
Hide file tree
Showing 16 changed files with 52 additions and 22 deletions.
2 changes: 1 addition & 1 deletion android/build.gradle
Expand Up @@ -44,7 +44,7 @@ repositories {
}

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'

implementation 'io.grpc:grpc-core:1.27.0-SNAPSHOT' // CURRENT_GRPC_VERSION
Expand Down
12 changes: 10 additions & 2 deletions build.gradle
Expand Up @@ -113,7 +113,7 @@ subprojects {
libraries = [
android_annotations: "com.google.android:annotations:4.1.1.4",
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",
guava: "com.google.guava:guava:${guavaVersion}",
hpack: 'com.twitter:hpack:0.10.1',
Expand Down Expand Up @@ -263,7 +263,7 @@ subprojects {

if (rootProject.properties.get('errorProne', true)) {
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'

annotationProcessor 'com.google.guava:guava-beta-checker:1.0'
Expand All @@ -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 {
// LinkedList doesn't hurt much in tests and has lots of usages
options.errorprone.check("JdkObsolete", CheckSeverity.OFF)
options.errorprone.check("UnnecessaryAnonymousClass", CheckSeverity.OFF)
options.errorprone.check("PreferJavaTimeOverload", CheckSeverity.OFF)
}
}

Expand Down
14 changes: 13 additions & 1 deletion core/build.gradle
Expand Up @@ -16,7 +16,10 @@ dependencies {
compile project(':grpc-api'),
libraries.gson,
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) {
// prefer our own versions instead of opencensus-api's dependency
exclude group: 'com.google.code.findbugs', module: 'jsr305'
Expand Down Expand Up @@ -56,3 +59,12 @@ animalsniffer {
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)
}
}
Expand Up @@ -3417,7 +3417,7 @@ public void start(Listener2 listener) {
public void shutdown() {}
}

final class FakeNameResolverFactory extends NameResolver.Factory {
final class FakeNameResolverFactory2 extends NameResolver.Factory {
FakeNameResolver resolver;

@Nullable
Expand All @@ -3432,7 +3432,7 @@ public String getDefaultScheme() {
}
}

FakeNameResolverFactory factory = new FakeNameResolverFactory();
FakeNameResolverFactory2 factory = new FakeNameResolverFactory2();
final class CustomBuilder extends AbstractManagedChannelImplBuilder<CustomBuilder> {

CustomBuilder() {
Expand Down
Expand Up @@ -3437,7 +3437,7 @@ public void start(Listener2 listener) {
public void shutdown() {}
}

final class FakeNameResolverFactory extends NameResolver.Factory {
final class FakeNameResolverFactory2 extends NameResolver.Factory {
FakeNameResolver resolver;

@Nullable
Expand All @@ -3452,7 +3452,7 @@ public String getDefaultScheme() {
}
}

FakeNameResolverFactory factory = new FakeNameResolverFactory();
FakeNameResolverFactory2 factory = new FakeNameResolverFactory2();
final class CustomBuilder extends AbstractManagedChannelImplBuilder<CustomBuilder> {

CustomBuilder() {
Expand Down
2 changes: 1 addition & 1 deletion cronet/build.gradle
Expand Up @@ -51,7 +51,7 @@ android {
}

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'

implementation 'io.grpc:grpc-core:1.27.0-SNAPSHOT' // CURRENT_GRPC_VERSION
Expand Down
Expand Up @@ -94,6 +94,7 @@ void setStream(CronetClientStream stream) {
}

@Override
@SuppressWarnings("GuardedBy")
public void run() {
assertTrue(stream != null);
stream.transportState().start(factory);
Expand Down
2 changes: 1 addition & 1 deletion examples/pom.xml
Expand Up @@ -65,7 +65,7 @@
<dependency>
<groupId>com.google.errorprone</groupId>
<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>
<groupId>junit</groupId>
Expand Down
Expand Up @@ -37,6 +37,7 @@ public class Util {
= 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. */
@SuppressWarnings("LiteProtoToString")
public static void assertEquals(MessageLite expected, MessageLite actual) {
if (expected == null || actual == null) {
Assert.assertEquals(expected, actual);
Expand Down
1 change: 1 addition & 0 deletions okhttp/BUILD.bazel
Expand Up @@ -12,6 +12,7 @@ java_library(
"//api",
"//core:internal",
"@com_google_code_findbugs_jsr305//jar",
"@com_google_errorprone_error_prone_annotations//jar",
"@com_google_guava_guava//jar",
"@com_google_j2objc_j2objc_annotations//jar",
"@com_squareup_okhttp_okhttp//jar",
Expand Down
Expand Up @@ -127,6 +127,7 @@ public void closed(
}

@Test
@SuppressWarnings("GuardedBy")
public void cancel_started() {
stream.start(new BaseClientStreamListener());
stream.transportState().start(1234);
Expand All @@ -145,6 +146,7 @@ public Void answer(InvocationOnMock invocation) throws Throwable {
}

@Test
@SuppressWarnings("GuardedBy")
public void start_alreadyCancelled() {
stream.start(new BaseClientStreamListener());
stream.cancel(Status.CANCELLED);
Expand All @@ -155,6 +157,7 @@ public void start_alreadyCancelled() {
}

@Test
@SuppressWarnings("GuardedBy")
public void start_userAgentRemoved() throws IOException {
Metadata metaData = new Metadata();
metaData.put(GrpcUtil.USER_AGENT_KEY, "misbehaving-application");
Expand All @@ -171,6 +174,7 @@ public void start_userAgentRemoved() throws IOException {
}

@Test
@SuppressWarnings("GuardedBy")
public void start_headerFieldOrder() throws IOException {
Metadata metaData = new Metadata();
metaData.put(GrpcUtil.USER_AGENT_KEY, "misbehaving-application");
Expand All @@ -194,6 +198,7 @@ public void start_headerFieldOrder() throws IOException {
}

@Test
@SuppressWarnings("GuardedBy")
public void start_headerPlaintext() throws IOException {
Metadata metaData = new Metadata();
metaData.put(GrpcUtil.USER_AGENT_KEY, "misbehaving-application");
Expand All @@ -218,6 +223,7 @@ public void start_headerPlaintext() throws IOException {
}

@Test
@SuppressWarnings("GuardedBy")
public void getUnaryRequest() throws IOException {
MethodDescriptor<?, ?> getMethod = MethodDescriptor.<Void, Void>newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
Expand Down
Expand Up @@ -2127,7 +2127,7 @@ void assertClosed() {
// The wait is safe; nextFrame is called in a loop and can have spurious wakeups
@SuppressWarnings("WaitNotInLoop")
@Override
public boolean nextFrame(Handler handler) throws IOException {
public boolean nextFrame(FrameReader.Handler handler) throws IOException {
Result result;
try {
result = nextResults.take();
Expand Down
Expand Up @@ -19,6 +19,7 @@

package io.grpc.okhttp.internal.framed;

import com.google.errorprone.annotations.FormatMethod;
import io.grpc.okhttp.internal.Protocol;
import java.io.IOException;
import java.util.List;
Expand Down Expand Up @@ -361,7 +362,7 @@ private void readWindowUpdate(
throws IOException {
if (length != 4) throw ioException("TYPE_WINDOW_UPDATE length !=4: %s", length);
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);
}

Expand Down Expand Up @@ -586,10 +587,12 @@ void frameHeader(int streamId, int length, byte type, byte flags) throws IOExcep
}
}

@FormatMethod
private static IllegalArgumentException illegalArgument(String message, Object... args) {
throw new IllegalArgumentException(format(message, args));
}

@FormatMethod
private static IOException ioException(String message, Object... args) throws IOException {
throw new IOException(format(message, args));
}
Expand Down
6 changes: 3 additions & 3 deletions repositories.bzl
Expand Up @@ -17,7 +17,7 @@ IO_GRPC_GRPC_JAVA_ARTIFACTS = [
"com.google.auth:google-auth-library-oauth2-http:0.19.0",
"com.google.code.findbugs:jsr305:3.0.2",
"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:guava:28.1-android",
"com.google.j2objc:j2objc-annotations:1.3",
Expand Down Expand Up @@ -226,9 +226,9 @@ def com_google_code_gson_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.3",
artifact = "com.google.errorprone:error_prone_annotations:2.3.4",
server_urls = ["https://repo.maven.apache.org/maven2/"],
artifact_sha256 = "ec59f1b702d9afc09e8c3929f5c42777dec623a6ea2731ac694332c7d7680f5a",
artifact_sha256 = "baf7d6ea97ce606c53e11b6854ba5f2ce7ef5c24dddf0afa18d1260bd25b002c",
licenses = ["notice"], # Apache 2.0
)

Expand Down
5 changes: 2 additions & 3 deletions services/src/main/java/io/grpc/services/BinlogHelper.java
Expand Up @@ -46,7 +46,6 @@
import io.grpc.MethodDescriptor;
import io.grpc.MethodDescriptor.Marshaller;
import io.grpc.ServerCall;
import io.grpc.ServerCall.Listener;
import io.grpc.ServerCallHandler;
import io.grpc.ServerInterceptor;
import io.grpc.Status;
Expand Down Expand Up @@ -408,7 +407,7 @@ public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall(

return new SimpleForwardingClientCall<ReqT, RespT>(next.newCall(method, callOptions)) {
@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
: Durations.fromNanos(deadline.timeRemaining(TimeUnit.NANOSECONDS));
writer.logClientHeader(
Expand Down Expand Up @@ -500,7 +499,7 @@ public void cancel(String message, Throwable cause) {
public ServerInterceptor getServerInterceptor(final long callId) {
return new ServerInterceptor() {
@Override
public <ReqT, RespT> Listener<ReqT> interceptCall(
public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(
final ServerCall<ReqT, RespT> call,
Metadata headers,
ServerCallHandler<ReqT, RespT> next) {
Expand Down
Expand Up @@ -36,7 +36,6 @@
import io.grpc.MethodDescriptor.Marshaller;
import io.grpc.MethodDescriptor.MethodType;
import io.grpc.ServerCall;
import io.grpc.ServerCall.Listener;
import io.grpc.ServerCallHandler;
import io.grpc.ServerInterceptor;
import io.grpc.ServerMethodDefinition;
Expand Down Expand Up @@ -127,7 +126,7 @@ public <RequestT, ResponseT> ClientCall<RequestT, ResponseT> newCall(
MethodDescriptor<RequestT, ResponseT> methodDescriptor, CallOptions callOptions) {
return new NoopClientCall<RequestT, ResponseT>() {
@Override
public void start(Listener<ResponseT> responseListener, Metadata headers) {
public void start(ClientCall.Listener<ResponseT> responseListener, Metadata headers) {
listener.set(responseListener);
}

Expand Down Expand Up @@ -211,7 +210,7 @@ public void wrapMethodDefinition_methodDescriptor() throws Exception {
method,
new ServerCallHandler<String, Integer>() {
@Override
public Listener<String> startCall(
public ServerCall.Listener<String> startCall(
ServerCall<String, Integer> call, Metadata headers) {
throw new UnsupportedOperationException();
}
Expand Down Expand Up @@ -310,7 +309,7 @@ public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall(
assertSame(BinaryLogProvider.BYTEARRAY_MARSHALLER, method.getResponseMarshaller());
return new SimpleForwardingClientCall<ReqT, RespT>(next.newCall(method, callOptions)) {
@Override
public void start(Listener<RespT> responseListener, Metadata headers) {
public void start(ClientCall.Listener<RespT> responseListener, Metadata headers) {
super.start(
new SimpleForwardingClientCallListener<RespT>(responseListener) {
@Override
Expand Down

0 comments on commit 75f6fd8

Please sign in to comment.