Skip to content

Commit

Permalink
Start building against Spring Framework 5.3.12 snapshots
Browse files Browse the repository at this point in the history
This reverts commit 196013f, reversing
changes made to 8b0c563.

Closes gh-28384
See gh-28241
  • Loading branch information
wilkinsona committed Oct 19, 2021
1 parent feed904 commit f2ef8f9
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 42 deletions.
Expand Up @@ -17,8 +17,6 @@
package org.springframework.boot.autoconfigure.web.reactive;

import java.time.Duration;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Expand Down Expand Up @@ -52,7 +50,6 @@
import org.springframework.context.annotation.Import;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.core.io.ResourceLoader;
import org.springframework.format.FormatterRegistry;
import org.springframework.format.support.FormattingConversionService;
import org.springframework.http.codec.ServerCodecConfigurer;
Expand Down Expand Up @@ -159,14 +156,12 @@ public static class WebFluxConfig implements WebFluxConfigurer {

private final ObjectProvider<ViewResolver> viewResolvers;

private final ResourceLoader resourceLoader;

public WebFluxConfig(org.springframework.boot.autoconfigure.web.ResourceProperties resourceProperties,
WebProperties webProperties, WebFluxProperties webFluxProperties, ListableBeanFactory beanFactory,
ObjectProvider<HandlerMethodArgumentResolver> resolvers,
ObjectProvider<CodecCustomizer> codecCustomizers,
ObjectProvider<ResourceHandlerRegistrationCustomizer> resourceHandlerRegistrationCustomizer,
ObjectProvider<ViewResolver> viewResolvers, ResourceLoader resourceLoader) {
ObjectProvider<ViewResolver> viewResolvers) {
this.resourceProperties = resourceProperties.hasBeenCustomized() ? resourceProperties
: webProperties.getResources();
this.webFluxProperties = webFluxProperties;
Expand All @@ -175,7 +170,6 @@ public WebFluxConfig(org.springframework.boot.autoconfigure.web.ResourceProperti
this.codecCustomizers = codecCustomizers;
this.resourceHandlerRegistrationCustomizer = resourceHandlerRegistrationCustomizer.getIfAvailable();
this.viewResolvers = viewResolvers;
this.resourceLoader = resourceLoader;
}

@Override
Expand All @@ -195,28 +189,17 @@ public void addResourceHandlers(ResourceHandlerRegistry registry) {
return;
}
if (!registry.hasMappingForPattern("/webjars/**")) {
String webjarsLocation = "classpath:/META-INF/resources/webjars/";
if (this.resourceLoader.getResource(webjarsLocation).exists()) {
ResourceHandlerRegistration registration = registry.addResourceHandler("/webjars/**")
.addResourceLocations(webjarsLocation);
configureResourceCaching(registration);
customizeResourceHandlerRegistration(registration);
}
ResourceHandlerRegistration registration = registry.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/");
configureResourceCaching(registration);
customizeResourceHandlerRegistration(registration);
}
String staticPathPattern = this.webFluxProperties.getStaticPathPattern();
if (!registry.hasMappingForPattern(staticPathPattern)) {
List<String> foundLocations = new ArrayList<>();
for (String staticLocation : this.resourceProperties.getStaticLocations()) {
if (this.resourceLoader.getResource(staticLocation).exists()) {
foundLocations.add(staticLocation);
}
}
if (!foundLocations.isEmpty()) {
ResourceHandlerRegistration registration = registry.addResourceHandler(staticPathPattern)
.addResourceLocations(foundLocations.toArray(new String[0]));
configureResourceCaching(registration);
customizeResourceHandlerRegistration(registration);
}
ResourceHandlerRegistration registration = registry.addResourceHandler(staticPathPattern)
.addResourceLocations(this.resourceProperties.getStaticLocations());
configureResourceCaching(registration);
customizeResourceHandlerRegistration(registration);
}
}

Expand Down
Expand Up @@ -201,8 +201,6 @@ public static class WebMvcAutoConfigurationAdapter implements WebMvcConfigurer,

private final ResourceHandlerRegistrationCustomizer resourceHandlerRegistrationCustomizer;

private final ResourceLoader resourceLoader;

private ServletContext servletContext;

public WebMvcAutoConfigurationAdapter(
Expand All @@ -211,7 +209,7 @@ public WebMvcAutoConfigurationAdapter(
ObjectProvider<HttpMessageConverters> messageConvertersProvider,
ObjectProvider<ResourceHandlerRegistrationCustomizer> resourceHandlerRegistrationCustomizerProvider,
ObjectProvider<DispatcherServletPath> dispatcherServletPath,
ObjectProvider<ServletRegistrationBean<?>> servletRegistrations, ResourceLoader resourceLoader) {
ObjectProvider<ServletRegistrationBean<?>> servletRegistrations) {
this.resourceProperties = resourceProperties.hasBeenCustomized() ? resourceProperties
: webProperties.getResources();
this.mvcProperties = mvcProperties;
Expand All @@ -220,7 +218,6 @@ public WebMvcAutoConfigurationAdapter(
this.resourceHandlerRegistrationCustomizer = resourceHandlerRegistrationCustomizerProvider.getIfAvailable();
this.dispatcherServletPath = dispatcherServletPath;
this.servletRegistrations = servletRegistrations;
this.resourceLoader = resourceLoader;
this.mvcProperties.checkConfiguration();
}

Expand Down Expand Up @@ -337,11 +334,7 @@ public void addResourceHandlers(ResourceHandlerRegistry registry) {
logger.debug("Default resource handling disabled");
return;
}
Resource webjarsLocationResource = this.resourceLoader
.getResource("classpath:/META-INF/resources/webjars/");
if (webjarsLocationResource.exists()) {
addResourceHandler(registry, "/webjars/**", webjarsLocationResource);
}
addResourceHandler(registry, "/webjars/**", "classpath:/META-INF/resources/webjars/");
addResourceHandler(registry, this.mvcProperties.getStaticPathPattern(), (registration) -> {
registration.addResourceLocations(this.resourceProperties.getStaticLocations());
if (this.servletContext != null) {
Expand All @@ -351,7 +344,7 @@ public void addResourceHandlers(ResourceHandlerRegistry registry) {
});
}

private void addResourceHandler(ResourceHandlerRegistry registry, String pattern, Resource... locations) {
private void addResourceHandler(ResourceHandlerRegistry registry, String pattern, String... locations) {
addResourceHandler(registry, pattern, (registration) -> registration.addResourceLocations(locations));
}

Expand Down
Expand Up @@ -157,10 +157,9 @@ void shouldRegisterResourceHandlerMapping() {
SimpleUrlHandlerMapping hm = context.getBean("resourceHandlerMapping", SimpleUrlHandlerMapping.class);
assertThat(hm.getUrlMap().get("/**")).isInstanceOf(ResourceWebHandler.class);
ResourceWebHandler staticHandler = (ResourceWebHandler) hm.getUrlMap().get("/**");
assertThat(staticHandler).extracting("locationValues").asList().hasSize(2);
assertThat(staticHandler.getLocations()).hasSize(2);
assertThat(staticHandler.getLocations().get(0)).hasToString("class path resource [META-INF/resources/]");
assertThat(staticHandler.getLocations().get(1)).hasToString("class path resource [public/]");
assertThat(staticHandler).extracting("locationValues").asList().hasSize(4);
assertThat(staticHandler.getLocations()).hasSize(1);
assertThat(staticHandler.getLocations().get(0)).hasToString("class path resource [public/]");
assertThat(hm.getUrlMap().get("/webjars/**")).isInstanceOf(ResourceWebHandler.class);
ResourceWebHandler webjarsHandler = (ResourceWebHandler) hm.getUrlMap().get("/webjars/**");
assertThat(webjarsHandler).extracting("locationValues").asList()
Expand All @@ -174,7 +173,7 @@ void shouldMapResourcesToCustomPath() {
SimpleUrlHandlerMapping hm = context.getBean("resourceHandlerMapping", SimpleUrlHandlerMapping.class);
assertThat(hm.getUrlMap().get("/static/**")).isInstanceOf(ResourceWebHandler.class);
ResourceWebHandler staticHandler = (ResourceWebHandler) hm.getUrlMap().get("/static/**");
assertThat(staticHandler).extracting("locationValues").asList().hasSize(2);
assertThat(staticHandler).extracting("locationValues").asList().hasSize(4);
});
}

Expand Down
Empty file.
2 changes: 1 addition & 1 deletion spring-boot-project/spring-boot-dependencies/build.gradle
Expand Up @@ -1663,7 +1663,7 @@ bom {
]
}
}
library("Spring Framework", "5.3.11") {
library("Spring Framework", "5.3.12-SNAPSHOT") {
group("org.springframework") {
imports = [
"spring-framework-bom"
Expand Down

0 comments on commit f2ef8f9

Please sign in to comment.