Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WW-5406 Fix injection order issue for excluded patterns #917

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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