Polish DefaultSecurityFilterChain Logs

Reuse String manipulation logic in Spring Framework
Compress whitespace

Closes gh-15096
This commit is contained in:
Josh Cummings 2024-05-23 12:20:14 -06:00
parent ac9bdf5cbf
commit 6956ed693c
No known key found for this signature in database
GPG Key ID: A306A51F43B8E5A5
1 changed files with 6 additions and 11 deletions

View File

@ -27,6 +27,7 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.core.log.LogMessage;
import org.springframework.security.web.util.matcher.RequestMatcher;
import org.springframework.util.StringUtils;
/**
* Standard implementation of {@code SecurityFilterChain}.
@ -52,18 +53,12 @@ public final class DefaultSecurityFilterChain implements SecurityFilterChain {
logger.debug(LogMessage.format("Will not secure %s", requestMatcher));
}
else {
StringBuilder filterClassNames = new StringBuilder();
String separator = ", ";
for (Filter f : filters) {
if (!filterClassNames.isEmpty()) {
filterClassNames.append(separator);
}
filterClassNames.append(f.getClass().getSimpleName());
List<String> filterNames = new ArrayList<>();
for (Filter filter : filters) {
filterNames.add(filter.getClass().getSimpleName());
}
logger.debug(
LogMessage.format("Will secure %s with filters: %s", requestMatcher, filterClassNames.toString()));
String names = StringUtils.collectionToDelimitedString(filterNames, ", ");
logger.debug(LogMessage.format("Will secure %s with filters: %s", requestMatcher, names));
}
this.requestMatcher = requestMatcher;
this.filters = new ArrayList<>(filters);