diff --git a/src/main/java/emissary/command/converter/PriorityDirectoryConverter.java b/src/main/java/emissary/command/converter/PriorityDirectoryConverter.java index 26d8d64627..9b9d91270f 100644 --- a/src/main/java/emissary/command/converter/PriorityDirectoryConverter.java +++ b/src/main/java/emissary/command/converter/PriorityDirectoryConverter.java @@ -6,6 +6,9 @@ import org.apache.commons.lang3.StringUtils; import picocli.CommandLine.ITypeConverter; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + public class PriorityDirectoryConverter implements ITypeConverter { public PriorityDirectoryConverter() { @@ -13,12 +16,14 @@ public PriorityDirectoryConverter() { } public static final String PRIORITY_DIR_REGEX = ".*:\\d+$"; + private static final Pattern priorityDirRegex = Pattern.compile(PRIORITY_DIR_REGEX); @Override public PriorityDirectory convert(String value) { final String dirName; final int priority; - if (value.matches(PRIORITY_DIR_REGEX)) { + Matcher matcher = priorityDirRegex.matcher(value); + if (matcher.matches()) { dirName = StringUtils.substringBeforeLast(value, ":"); priority = Integer.parseInt(StringUtils.substringAfterLast(value, ":")); } else {