Optimize ResourceUrlProvider

Closes gh-2008
This commit is contained in:
Kamil Szymanski 2018-12-11 12:12:15 +01:00 committed by Brian Clozel
parent 0550c08f86
commit 894044cea0
1 changed files with 1 additions and 2 deletions

View File

@ -144,9 +144,8 @@ public class ResourceUrlProvider implements ApplicationListener<ContextRefreshed
private Mono<String> resolveResourceUrl(ServerWebExchange exchange, PathContainer lookupPath) {
return this.handlerMap.entrySet().stream()
.filter(entry -> entry.getKey().matches(lookupPath))
.sorted((entry1, entry2) ->
.min((entry1, entry2) ->
PathPattern.SPECIFICITY_COMPARATOR.compare(entry1.getKey(), entry2.getKey()))
.findFirst()
.map(entry -> {
PathContainer path = entry.getKey().extractPathWithinPattern(lookupPath);
int endIndex = lookupPath.elements().size() - path.elements().size();