services: fix lint warnings on binlog (#3927)
diff --git a/services/src/main/java/io/grpc/services/BinaryLog.java b/services/src/main/java/io/grpc/services/BinaryLog.java
index 6e1f74b..522051b 100644
--- a/services/src/main/java/io/grpc/services/BinaryLog.java
+++ b/services/src/main/java/io/grpc/services/BinaryLog.java
@@ -19,6 +19,7 @@
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
+import com.google.common.base.Splitter;
import com.google.common.primitives.Bytes;
import com.google.protobuf.ByteString;
import io.grpc.InternalMetadata;
@@ -145,8 +146,7 @@
Map<String, BinaryLog> perServiceLogs = new HashMap<String, BinaryLog>();
Map<String, BinaryLog> perMethodLogs = new HashMap<String, BinaryLog>();
- String[] configurations = configurationString.split(",");
- for (String configuration : configurations) {
+ for (String configuration : Splitter.on(',').split(configurationString)) {
Matcher configMatcher = configRe.matcher(configuration);
if (!configMatcher.matches()) {
throw new IllegalArgumentException("Bad input: " + configuration);
@@ -273,7 +273,8 @@
// TODO(zpencer): verify int64 representation with other gRPC languages
static Uint128 callIdToProto(byte[] bytes) {
Preconditions.checkArgument(
- bytes.length == 16, "can only convert from 16 byte input, actual length =" + bytes.length);
+ bytes.length == 16,
+ String.format("can only convert from 16 byte input, actual length = %d", bytes.length));
ByteBuffer bb = ByteBuffer.wrap(bytes);
long high = bb.getLong();
long low = bb.getLong();
diff --git a/services/src/test/java/io/grpc/services/BinaryLogTest.java b/services/src/test/java/io/grpc/services/BinaryLogTest.java
index fa59977..de95d15 100644
--- a/services/src/test/java/io/grpc/services/BinaryLogTest.java
+++ b/services/src/test/java/io/grpc/services/BinaryLogTest.java
@@ -54,9 +54,9 @@
private static final BinaryLog BOTH_FULL =
new Builder().header(Integer.MAX_VALUE).msg(Integer.MAX_VALUE).build();
- private static final String dataA = "aaaaaaaaa";
- private static final String dataB = "bbbbbbbbb";
- private static final String dataC = "ccccccccc";
+ private static final String DATA_A = "aaaaaaaaa";
+ private static final String DATA_B = "bbbbbbbbb";
+ private static final String DATA_C = "ccccccccc";
private static final Metadata.Key<String> KEY_A =
Metadata.Key.of("a", Metadata.ASCII_STRING_MARSHALLER);
private static final Metadata.Key<String> KEY_B =
@@ -67,19 +67,19 @@
MetadataEntry
.newBuilder()
.setKey(ByteString.copyFrom(KEY_A.name(), US_ASCII))
- .setValue(ByteString.copyFrom(dataA.getBytes(US_ASCII)))
+ .setValue(ByteString.copyFrom(DATA_A.getBytes(US_ASCII)))
.build();
private static final MetadataEntry ENTRY_B =
MetadataEntry
.newBuilder()
.setKey(ByteString.copyFrom(KEY_B.name(), US_ASCII))
- .setValue(ByteString.copyFrom(dataB.getBytes(US_ASCII)))
+ .setValue(ByteString.copyFrom(DATA_B.getBytes(US_ASCII)))
.build();
private static final MetadataEntry ENTRY_C =
MetadataEntry
.newBuilder()
.setKey(ByteString.copyFrom(KEY_C.name(), US_ASCII))
- .setValue(ByteString.copyFrom(dataC.getBytes(US_ASCII)))
+ .setValue(ByteString.copyFrom(DATA_C.getBytes(US_ASCII)))
.build();
private static final boolean IS_COMPRESSED = true;
private static final boolean IS_UNCOMPRESSED = false;
@@ -88,9 +88,9 @@
@Before
public void setUp() throws Exception {
- metadata.put(KEY_A, dataA);
- metadata.put(KEY_B, dataB);
- metadata.put(KEY_C, dataC);
+ metadata.put(KEY_A, DATA_A);
+ metadata.put(KEY_B, DATA_B);
+ metadata.put(KEY_C, DATA_C);
}
@Test
@@ -373,15 +373,11 @@
public void metadataToProto_truncated() throws Exception {
// 0 byte limit not enough for any metadata
assertEquals(
- io.grpc.binarylog.Metadata
- .newBuilder()
- .build(),
+ io.grpc.binarylog.Metadata.getDefaultInstance(),
BinaryLog.metadataToProto(metadata, 0));
// not enough bytes for first key value
assertEquals(
- io.grpc.binarylog.Metadata
- .newBuilder()
- .build(),
+ io.grpc.binarylog.Metadata.getDefaultInstance(),
BinaryLog.metadataToProto(metadata, 9));
// enough for first key value
assertEquals(