Use Matcher from pre-compiled Pattern rather than String for replaceAll
Closes gh-14483
This commit is contained in:
@@ -21,6 +21,7 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.junit.rules.TestRule;
|
||||
import org.junit.runner.Description;
|
||||
@@ -36,12 +37,14 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
class JvmLauncher implements TestRule {
|
||||
|
||||
private static final Pattern NON_ALPHABET_PATTERN = Pattern.compile("[^A-Za-z]+");
|
||||
|
||||
private File outputDirectory;
|
||||
|
||||
@Override
|
||||
public Statement apply(Statement base, Description description) {
|
||||
this.outputDirectory = new File("target/output/"
|
||||
+ description.getMethodName().replaceAll("[^A-Za-z]+", ""));
|
||||
this.outputDirectory = new File("target/output/" + NON_ALPHABET_PATTERN
|
||||
.matcher(description.getMethodName()).replaceAll(""));
|
||||
this.outputDirectory.mkdirs();
|
||||
return base;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user