Enable the Guava Beta Checker

This commit is contained in:
Eric Anderson 2018-01-08 14:05:16 -08:00
parent c9657d3e6d
commit 35a6bf863d
10 changed files with 19 additions and 3 deletions

View File

@ -167,6 +167,7 @@ final class GoogleAuthLibraryCallCredentials implements CallCredentials {
} }
} }
@SuppressWarnings("BetaApi") // BaseEncoding is stable in Guava 20.0
private static Metadata toHeaders(@Nullable Map<String, List<String>> metadata) { private static Metadata toHeaders(@Nullable Map<String, List<String>> metadata) {
Metadata headers = new Metadata(); Metadata headers = new Metadata();
if (metadata != null) { if (metadata != null) {

View File

@ -9,7 +9,8 @@ buildscript {
dependencies { dependencies {
classpath 'com.google.gradle:osdetector-gradle-plugin:1.4.0' classpath 'com.google.gradle:osdetector-gradle-plugin:1.4.0'
classpath 'ru.vyarus:gradle-animalsniffer-plugin:1.4.0' classpath 'ru.vyarus:gradle-animalsniffer-plugin:1.4.0'
classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.11' classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.13'
classpath 'net.ltgt.gradle:gradle-apt-plugin:0.13'
classpath "me.champeau.gradle:jmh-gradle-plugin:0.4.4" classpath "me.champeau.gradle:jmh-gradle-plugin:0.4.4"
classpath 'me.champeau.gradle:japicmp-gradle-plugin:0.2.5' classpath 'me.champeau.gradle:japicmp-gradle-plugin:0.2.5'
} }
@ -29,11 +30,13 @@ subprojects {
apply plugin: "ru.vyarus.animalsniffer" apply plugin: "ru.vyarus.animalsniffer"
if (!rootProject.hasProperty('errorProne') || rootProject.errorProne.toBoolean()) { if (!rootProject.hasProperty('errorProne') || rootProject.errorProne.toBoolean()) {
apply plugin: "net.ltgt.errorprone" apply plugin: "net.ltgt.errorprone"
apply plugin: "net.ltgt.apt"
dependencies { dependencies {
// The ErrorProne plugin defaults to the latest, which would break our // The ErrorProne plugin defaults to the latest, which would break our
// build if error prone releases a new version with a new check // build if error prone releases a new version with a new check
errorprone 'com.google.errorprone:error_prone_core:2.0.21' errorprone 'com.google.errorprone:error_prone_core:2.0.21'
apt 'com.google.guava:guava-beta-checker:1.0'
} }
} else { } else {
// Remove per-project error-prone checker config // Remove per-project error-prone checker config

View File

@ -455,6 +455,7 @@ public final class Metadata {
} }
} }
@SuppressWarnings("BetaApi") // BaseEncoding is stable in Guava 20.0
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder("Metadata("); StringBuilder sb = new StringBuilder("Metadata(");

View File

@ -371,6 +371,7 @@ final class DnsNameResolver extends NameResolver {
private static final Pattern whitespace = Pattern.compile("\\s+"); private static final Pattern whitespace = Pattern.compile("\\s+");
@SuppressWarnings("BetaApi") // Verify is stable in Guava 23.5
@Override @Override
ResolutionResults resolve(String host) throws NamingException { ResolutionResults resolve(String host) throws NamingException {
List<String> serviceConfigTxtRecords = Collections.emptyList(); List<String> serviceConfigTxtRecords = Collections.emptyList();

View File

@ -44,6 +44,7 @@ public final class TransportFrameUtil {
* *
* @return the interleaved keys and values. * @return the interleaved keys and values.
*/ */
@SuppressWarnings("BetaApi") // BaseEncoding is stable in Guava 20.0
public static byte[][] toHttp2Headers(Metadata headers) { public static byte[][] toHttp2Headers(Metadata headers) {
byte[][] serializedHeaders = InternalMetadata.serialize(headers); byte[][] serializedHeaders = InternalMetadata.serialize(headers);
// TODO(carl-mastrangelo): eventually remove this once all callers are updated. // TODO(carl-mastrangelo): eventually remove this once all callers are updated.
@ -89,6 +90,7 @@ public final class TransportFrameUtil {
* @param http2Headers the interleaved keys and values of HTTP/2-compliant headers * @param http2Headers the interleaved keys and values of HTTP/2-compliant headers
* @return the interleaved keys and values in the raw serialized format * @return the interleaved keys and values in the raw serialized format
*/ */
@SuppressWarnings("BetaApi") // BaseEncoding is stable in Guava 20.0
public static byte[][] toRawSerializedHeaders(byte[][] http2Headers) { public static byte[][] toRawSerializedHeaders(byte[][] http2Headers) {
for (int i = 0; i < http2Headers.length; i += 2) { for (int i = 0; i < http2Headers.length; i += 2) {
byte[] key = http2Headers[i]; byte[] key = http2Headers[i];

View File

@ -32,6 +32,11 @@ dependencies {
configureProtoCompilation() configureProtoCompilation()
compileJava {
// This isn't a library; it can use beta APIs
it.options.compilerArgs += ["-Xep:BetaApi:OFF"]
}
test { test {
// For the automated tests, use Jetty ALPN. // For the automated tests, use Jetty ALPN.
jvmArgs "-javaagent:" + configurations.alpnagent.asPath jvmArgs "-javaagent:" + configurations.alpnagent.asPath

View File

@ -179,6 +179,7 @@ class GrpcHttp2HeadersUtils {
return PlatformDependent.equals(bytes0, offset0, bytes1, offset1, length0); return PlatformDependent.equals(bytes0, offset0, bytes1, offset1, length0);
} }
@SuppressWarnings("BetaApi") // BaseEncoding is stable in Guava 20.0
private static byte[] toBinaryValue(AsciiString name, AsciiString value) { private static byte[] toBinaryValue(AsciiString name, AsciiString value) {
return name.endsWith(binaryHeaderSuffix) return name.endsWith(binaryHeaderSuffix)
? BaseEncoding.base64().decode(value) ? BaseEncoding.base64().decode(value)

View File

@ -111,6 +111,7 @@ class NettyClientStream extends AbstractClientStream {
} }
private class Sink implements AbstractClientStream.Sink { private class Sink implements AbstractClientStream.Sink {
@SuppressWarnings("BetaApi") // BaseEncoding is stable in Guava 20.0
@Override @Override
public void writeHeaders(Metadata headers, byte[] requestPayload) { public void writeHeaders(Metadata headers, byte[] requestPayload) {
// Convert the headers into Netty HTTP/2 headers. // Convert the headers into Netty HTTP/2 headers.

View File

@ -126,6 +126,7 @@ class OkHttpClientStream extends AbstractClientStream {
} }
class Sink implements AbstractClientStream.Sink { class Sink implements AbstractClientStream.Sink {
@SuppressWarnings("BetaApi") // BaseEncoding is stable in Guava 20.0
@Override @Override
public void writeHeaders(Metadata metadata, byte[] payload) { public void writeHeaders(Metadata metadata, byte[] payload) {
String defaultPath = "/" + method.getFullMethodName(); String defaultPath = "/" + method.getFullMethodName();

View File

@ -41,7 +41,6 @@ import static org.mockito.Mockito.when;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.io.ByteStreams;
import com.google.common.util.concurrent.MoreExecutors; import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.SettableFuture; import com.google.common.util.concurrent.SettableFuture;
import io.grpc.Attributes; import io.grpc.Attributes;
@ -57,6 +56,7 @@ import io.grpc.internal.ClientStream;
import io.grpc.internal.ClientStreamListener; import io.grpc.internal.ClientStreamListener;
import io.grpc.internal.ClientTransport; import io.grpc.internal.ClientTransport;
import io.grpc.internal.InternalServer; import io.grpc.internal.InternalServer;
import io.grpc.internal.IoUtils;
import io.grpc.internal.ManagedClientTransport; import io.grpc.internal.ManagedClientTransport;
import io.grpc.internal.ServerListener; import io.grpc.internal.ServerListener;
import io.grpc.internal.ServerStream; import io.grpc.internal.ServerStream;
@ -1954,7 +1954,7 @@ public abstract class AbstractTransportTest {
@Override @Override
public String parse(InputStream stream) { public String parse(InputStream stream) {
try { try {
return new String(ByteStreams.toByteArray(stream), UTF_8); return new String(IoUtils.toByteArray(stream), UTF_8);
} catch (IOException ex) { } catch (IOException ex) {
throw new RuntimeException(ex); throw new RuntimeException(ex);
} }