diff --git a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java index af5bb5402f..a1f9094d1c 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java @@ -167,8 +167,9 @@ public class Dispatcher { */ private Pattern multipartValidationPattern = Pattern.compile(MULTIPART_FORM_DATA_REGEX); + private String actionExcludedPatternsStr; private String actionExcludedPatternsSeparator = ","; - private List actionExcludedPatterns = emptyList(); + private List actionExcludedPatterns; /** * Provide list of default configuration files. @@ -355,18 +356,24 @@ public void setActionExcludedPatternsSeparator(String separator) { @Inject(value = StrutsConstants.STRUTS_ACTION_EXCLUDE_PATTERN, required = false) public void setActionExcludedPatterns(String excludedPatterns) { - this.actionExcludedPatterns = buildExcludedPatternsList(excludedPatterns, actionExcludedPatternsSeparator); + this.actionExcludedPatternsStr = excludedPatterns; } - private static List buildExcludedPatternsList(String patterns, String separator) { - if (patterns == null || patterns.trim().isEmpty()) { - return emptyList(); + public List getActionExcludedPatterns() { + if (actionExcludedPatterns == null) { + initActionExcludedPatterns(); } - return unmodifiableList(Arrays.stream(patterns.split(separator)).map(String::trim).map(Pattern::compile).collect(toList())); + return actionExcludedPatterns; } - public List getActionExcludedPatterns() { - return actionExcludedPatterns; + private void initActionExcludedPatterns() { + if (actionExcludedPatternsStr == null || actionExcludedPatternsStr.trim().isEmpty()) { + actionExcludedPatterns = emptyList(); + return; + } + actionExcludedPatterns = unmodifiableList( + Arrays.stream(actionExcludedPatternsStr.split(actionExcludedPatternsSeparator)) + .map(String::trim).map(Pattern::compile).collect(toList())); } @Inject