Use Matcher from pre-compiled Pattern rather than String for replaceAll

Closes gh-14483
This commit is contained in:
durigon
2018-09-16 11:42:49 +09:00
committed by Andy Wilkinson
parent 11016bc7f4
commit 7aaeefbc0e
8 changed files with 44 additions and 10 deletions

View File

@@ -24,6 +24,7 @@ import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Pattern;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathExpression;
@@ -50,6 +51,9 @@ import org.springframework.util.FileCopyUtils;
*/
public class GradleBuild implements TestRule {
private static final Pattern GRADLE_VERSION_PATTERN = Pattern
.compile("\\[Gradle .+\\]");
private final TemporaryFolder temp = new TemporaryFolder();
private File projectDir;
@@ -95,7 +99,7 @@ public class GradleBuild implements TestRule {
}
private String removeGradleVersion(String methodName) {
return methodName.replaceAll("\\[Gradle .+\\]", "").trim();
return GRADLE_VERSION_PATTERN.matcher(methodName).replaceAll("").trim();
}
private URL getScriptForTestClass(Class<?> testClass) {