aboutsummaryrefslogtreecommitdiff
path: root/services
diff options
context:
space:
mode:
authorNathan Herring <Capstan@users.noreply.github.com>2018-05-30 21:26:02 +0200
committerCarl Mastrangelo <notcarl@google.com>2018-05-30 12:26:02 -0700
commit8db8497ef0d603510175471db21ee27092dd7969 (patch)
treea0250faa12539dc3fdc1abb594862e596e452d3e /services
parentf3ef2850a9c5e04b45d3a68ab86034aec57ccc4f (diff)
downloadgrpc-grpc-java-8db8497ef0d603510175471db21ee27092dd7969.tar.gz
services: use RE2/J
RE2/J ensures linear time matching, and as such is preferred over `java.util.regex` for safety in the mono repo. While currently safe, this conversion future-proofs any `Pattern`s in BinlogHelper, and removes the need to maintain an exception for gRPC wrt. use of regexes.
Diffstat (limited to 'services')
-rw-r--r--services/build.gradle1
-rw-r--r--services/src/main/java/io/grpc/services/BinlogHelper.java4
2 files changed, 3 insertions, 2 deletions
diff --git a/services/build.gradle b/services/build.gradle
index f9c34337d..b865cd55e 100644
--- a/services/build.gradle
+++ b/services/build.gradle
@@ -20,6 +20,7 @@ dependencies {
// prefer 20.0 from libraries instead of 19.0
exclude group: 'com.google.guava', module: 'guava'
}
+ compile libraries.re2j
compileOnly libraries.javax_annotation
testCompile project(':grpc-testing'),
diff --git a/services/src/main/java/io/grpc/services/BinlogHelper.java b/services/src/main/java/io/grpc/services/BinlogHelper.java
index 1d8d1443f..727208453 100644
--- a/services/src/main/java/io/grpc/services/BinlogHelper.java
+++ b/services/src/main/java/io/grpc/services/BinlogHelper.java
@@ -22,6 +22,8 @@ import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.common.base.Splitter;
import com.google.protobuf.ByteString;
+import com.google.re2j.Matcher;
+import com.google.re2j.Pattern;
import io.grpc.Attributes;
import io.grpc.BinaryLog.CallId;
import io.grpc.CallOptions;
@@ -60,8 +62,6 @@ import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;