Skip to content

Commit 4486ab1

Browse files
kilinkbclozel
authored andcommitted
Initialize Map with correct size in RequestPredicates
Fix another instance where a LinkedHashMap was initialized with an initial capacity that would always cause a resize / rehash to occur. Switch to CollectionUtils.newLinkedHashMap to size the map appropiately for the expected number of items. Closes gh-32215
1 parent 78c96b6 commit 4486ab1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

spring-webmvc/src/main/java/org/springframework/web/servlet/function/RequestPredicates.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1237,7 +1237,7 @@ private static Map<String, Object> mergeAttributes(ServerRequest request, Map<St
12371237
PathPattern oldPathPattern = (PathPattern) request.attribute(RouterFunctions.MATCHING_PATTERN_ATTRIBUTE)
12381238
.orElse(null);
12391239

1240-
Map<String, Object> result = new LinkedHashMap<>(2);
1240+
Map<String, Object> result = CollectionUtils.newLinkedHashMap(2);
12411241
result.put(RouterFunctions.URI_TEMPLATE_VARIABLES_ATTRIBUTE, mergeMaps(oldPathVariables, newPathVariables));
12421242
result.put(RouterFunctions.MATCHING_PATTERN_ATTRIBUTE, mergePatterns(oldPathPattern, newPathPattern));
12431243
return result;

0 commit comments

Comments
 (0)