|
21 | 21 | import java.util.Collection; |
22 | 22 | import java.util.Collections; |
23 | 23 | import java.util.List; |
| 24 | +import java.util.function.Supplier; |
24 | 25 | import java.util.stream.Collectors; |
25 | 26 |
|
26 | 27 | import org.springframework.beans.BeansException; |
|
64 | 65 | import org.springframework.security.web.server.WebFilterChainProxy; |
65 | 66 | import org.springframework.security.web.server.util.matcher.ServerWebExchangeMatcher; |
66 | 67 | import org.springframework.security.web.server.util.matcher.ServerWebExchangeMatchers; |
| 68 | +import org.springframework.util.function.SingletonSupplier; |
67 | 69 | import org.springframework.web.cors.CorsConfiguration; |
68 | 70 | import org.springframework.web.reactive.function.client.WebClient; |
69 | 71 | import org.springframework.web.server.WebFilter; |
@@ -156,25 +158,26 @@ private CorsConfiguration getCorsConfiguration() { |
156 | 158 | static class IgnoredPathsSecurityConfiguration { |
157 | 159 |
|
158 | 160 | @Bean |
159 | | - WebFilterChainPostProcessor webFilterChainPostProcessor( |
160 | | - CloudFoundryWebFluxEndpointHandlerMapping handlerMapping) { |
| 161 | + static WebFilterChainPostProcessor webFilterChainPostProcessor( |
| 162 | + ObjectProvider<CloudFoundryWebFluxEndpointHandlerMapping> handlerMapping) { |
161 | 163 | return new WebFilterChainPostProcessor(handlerMapping); |
162 | 164 | } |
163 | 165 |
|
164 | 166 | } |
165 | 167 |
|
166 | 168 | static class WebFilterChainPostProcessor implements BeanPostProcessor { |
167 | 169 |
|
168 | | - private final PathMappedEndpoints pathMappedEndpoints; |
| 170 | + private Supplier<PathMappedEndpoints> pathMappedEndpoints; |
169 | 171 |
|
170 | | - WebFilterChainPostProcessor(CloudFoundryWebFluxEndpointHandlerMapping handlerMapping) { |
171 | | - this.pathMappedEndpoints = new PathMappedEndpoints(BASE_PATH, handlerMapping::getAllEndpoints); |
| 172 | + WebFilterChainPostProcessor(ObjectProvider<CloudFoundryWebFluxEndpointHandlerMapping> handlerMapping) { |
| 173 | + this.pathMappedEndpoints = SingletonSupplier |
| 174 | + .of(() -> new PathMappedEndpoints(BASE_PATH, () -> handlerMapping.getObject().getAllEndpoints())); |
172 | 175 | } |
173 | 176 |
|
174 | 177 | @Override |
175 | 178 | public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { |
176 | 179 | if (bean instanceof WebFilterChainProxy) { |
177 | | - return postProcess((WebFilterChainProxy) bean, this.pathMappedEndpoints); |
| 180 | + return postProcess((WebFilterChainProxy) bean, this.pathMappedEndpoints.get()); |
178 | 181 | } |
179 | 182 | return bean; |
180 | 183 | } |
|
0 commit comments