Skip to content

Commit 26ee30e

Browse files
committed
Merge branch '6.2.x'
2 parents 20ddd9f + 63db3d0 commit 26ee30e

File tree

4 files changed

+37
-13
lines changed

4 files changed

+37
-13
lines changed

framework-docs/modules/ROOT/pages/web/webflux/controller/ann-methods/multipart-forms.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Java::
1919
2020
private String name;
2121
22-
private MultipartFile file;
22+
private FilePart file;
2323
2424
// ...
2525
@@ -42,7 +42,7 @@ Kotlin::
4242
----
4343
class MyForm(
4444
val name: String,
45-
val file: MultipartFile)
45+
val file: FilePart)
4646
4747
@Controller
4848
class FileUploadController {

spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ ResponseSpec onRawStatus(IntPredicate statusCodePredicate,
839839
<T> Flux<T> bodyToFlux(Class<T> elementClass);
840840

841841
/**
842-
* Variant of {@link #bodyToMono(Class)} with a {@link ParameterizedTypeReference}.
842+
* Variant of {@link #bodyToFlux(Class)} with a {@link ParameterizedTypeReference}.
843843
* @param elementTypeRef the type of element to decode to
844844
* @param <T> the body element type
845845
* @return the decoded body
@@ -859,7 +859,7 @@ ResponseSpec onRawStatus(IntPredicate statusCodePredicate,
859859
<T> Mono<ResponseEntity<T>> toEntity(Class<T> bodyClass);
860860

861861
/**
862-
* Variant of {@link #bodyToMono(Class)} with a {@link ParameterizedTypeReference}.
862+
* Variant of {@link #toEntity(Class)} with a {@link ParameterizedTypeReference}.
863863
* @param bodyTypeReference the expected response body type
864864
* @param <T> the response body type
865865
* @return the {@code ResponseEntity} with the decoded body
@@ -881,7 +881,7 @@ ResponseSpec onRawStatus(IntPredicate statusCodePredicate,
881881
<T> Mono<ResponseEntity<List<T>>> toEntityList(Class<T> elementClass);
882882

883883
/**
884-
* Variant of {@link #toEntity(Class)} with a {@link ParameterizedTypeReference}.
884+
* Variant of {@link #toEntityList(Class)} with a {@link ParameterizedTypeReference}.
885885
* @param elementTypeRef the type of element to decode the target Flux to
886886
* @param <T> the body element type
887887
* @return the {@code ResponseEntity}

spring-webmvc/src/main/java/org/springframework/web/servlet/handler/HandlerMappingIntrospector.java

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -104,16 +104,39 @@ public class HandlerMappingIntrospector
104104
private static final String CACHED_RESULT_ATTRIBUTE =
105105
HandlerMappingIntrospector.class.getName() + ".CachedResult";
106106

107+
private static final int DEFAULT_CACHE_LIMIT = 2048;
108+
107109

108110
private @Nullable ApplicationContext applicationContext;
109111

110112
private @Nullable List<HandlerMapping> handlerMappings;
111113

112114
private Map<HandlerMapping, PathPatternMatchableHandlerMapping> pathPatternMappings = Collections.emptyMap();
113115

116+
private int patternCacheLimit = DEFAULT_CACHE_LIMIT;
117+
114118
private final CacheResultLogHelper cacheLogHelper = new CacheResultLogHelper();
115119

116120

121+
/**
122+
* Set a limit on the maximum number of security patterns passed into
123+
* {@link MatchableHandlerMapping#match} at runtime to cache.
124+
* <p>By default, this is set to 2048.
125+
* @param patternCacheLimit the limit to use
126+
* @since 6.2.8
127+
*/
128+
public void setPatternCacheLimit(int patternCacheLimit) {
129+
this.patternCacheLimit = patternCacheLimit;
130+
}
131+
132+
/**
133+
* Return the configured limit on security patterns to cache.
134+
* @since 6.2.8
135+
*/
136+
public int getPatternCacheLimit() {
137+
return this.patternCacheLimit;
138+
}
139+
117140
@Override
118141
public void setApplicationContext(ApplicationContext applicationContext) {
119142
this.applicationContext = applicationContext;
@@ -127,8 +150,9 @@ public void afterPropertiesSet() {
127150

128151
this.pathPatternMappings = this.handlerMappings.stream()
129152
.filter(m -> m instanceof MatchableHandlerMapping hm && hm.getPatternParser() != null)
130-
.map(mapping -> (MatchableHandlerMapping) mapping)
131-
.collect(Collectors.toMap(mapping -> mapping, PathPatternMatchableHandlerMapping::new));
153+
.map(hm -> (MatchableHandlerMapping) hm)
154+
.collect(Collectors.toMap(hm -> hm, (MatchableHandlerMapping delegate) ->
155+
new PathPatternMatchableHandlerMapping(delegate, getPatternCacheLimit())));
132156
}
133157
}
134158

spring-webmvc/src/main/java/org/springframework/web/servlet/handler/PathPatternMatchableHandlerMapping.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,29 +42,29 @@
4242
@Deprecated(since = "7.0", forRemoval = true)
4343
class PathPatternMatchableHandlerMapping implements MatchableHandlerMapping {
4444

45-
private static final int MAX_PATTERNS = 1024;
46-
47-
4845
private final MatchableHandlerMapping delegate;
4946

5047
private final PathPatternParser parser;
5148

5249
private final Map<String, PathPattern> pathPatternCache = new ConcurrentHashMap<>();
5350

51+
private final int cacheLimit;
52+
5453

55-
public PathPatternMatchableHandlerMapping(MatchableHandlerMapping delegate) {
54+
public PathPatternMatchableHandlerMapping(MatchableHandlerMapping delegate, int cacheLimit) {
5655
Assert.notNull(delegate, "HandlerMapping to delegate to is required.");
5756
Assert.notNull(delegate.getPatternParser(), "Expected HandlerMapping configured to use PatternParser.");
5857
this.delegate = delegate;
5958
this.parser = delegate.getPatternParser();
59+
this.cacheLimit = cacheLimit;
6060
}
6161

6262
@SuppressWarnings("removal")
6363
@Deprecated(since = "7.0", forRemoval = true)
6464
@Override
6565
public @Nullable RequestMatchResult match(HttpServletRequest request, String pattern) {
6666
PathPattern pathPattern = this.pathPatternCache.computeIfAbsent(pattern, value -> {
67-
Assert.state(this.pathPatternCache.size() < MAX_PATTERNS, "Max size for pattern cache exceeded.");
67+
Assert.state(this.pathPatternCache.size() < this.cacheLimit, "Max size for pattern cache exceeded.");
6868
return this.parser.parse(pattern);
6969
});
7070
PathContainer path = ServletRequestPathUtils.getParsedRequestPath(request).pathWithinApplication();

0 commit comments

Comments
 (0)