[errorprone] Use Guava Splitter to avoid String#split
See https://errorprone.info/bugpattern/StringSplitter
Change-Id: I73aa8dc652e17025df84c71e1313c0682e229051
diff --git a/java/com/google/gitiles/FormatType.java b/java/com/google/gitiles/FormatType.java
index 3a2579a..8751937 100644
--- a/java/com/google/gitiles/FormatType.java
+++ b/java/com/google/gitiles/FormatType.java
@@ -15,6 +15,7 @@
package com.google.gitiles;
import com.google.common.base.Enums;
+import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import com.google.common.net.HttpHeaders;
import java.util.Optional;
@@ -29,6 +30,8 @@
private static final String FORMAT_TYPE_ATTRIBUTE = FormatType.class.getName();
+ private static final Splitter SPLITTER = Splitter.onPattern("[ ,;][ ,;]*");
+
public static Optional<FormatType> getFormatType(HttpServletRequest req) {
@SuppressWarnings("unchecked")
Optional<FormatType> result = (Optional<FormatType>) req.getAttribute(FORMAT_TYPE_ATTRIBUTE);
@@ -47,7 +50,7 @@
return set(req, Optional.of(DEFAULT));
}
- for (String p : accept.split("[ ,;][ ,;]*")) {
+ for (String p : SPLITTER.split(accept)) {
for (FormatType type : FormatType.values()) {
if (p.equals(type.mimeType)) {
return set(req, Optional.of(type != HTML ? type : DEFAULT));