Skip to content

Commit

Permalink
WW-5406 Fix injection order issue for excluded patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
kusalk committed Apr 18, 2024
1 parent 1562e66 commit ad49ea8
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,9 @@ public class Dispatcher {
*/
private Pattern multipartValidationPattern = Pattern.compile(MULTIPART_FORM_DATA_REGEX);

private String actionExcludedPatternsStr;
private String actionExcludedPatternsSeparator = ",";
private List<Pattern> actionExcludedPatterns = emptyList();
private List<Pattern> actionExcludedPatterns;

/**
* Provide list of default configuration files.
Expand Down Expand Up @@ -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<Pattern> buildExcludedPatternsList(String patterns, String separator) {
if (patterns == null || patterns.trim().isEmpty()) {
return emptyList();
public List<Pattern> getActionExcludedPatterns() {
if (actionExcludedPatterns == null) {
initActionExcludedPatterns();
}
return unmodifiableList(Arrays.stream(patterns.split(separator)).map(String::trim).map(Pattern::compile).collect(toList()));
return actionExcludedPatterns;
}

public List<Pattern> 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
Expand Down

0 comments on commit ad49ea8

Please sign in to comment.