From 5d6e143ff4ec3e10a4b8755cfa971b382fcaaddb Mon Sep 17 00:00:00 2001 From: Sam Brannen <104798+sbrannen@users.noreply.github.com> Date: Mon, 24 Jun 2024 16:32:14 +0200 Subject: [PATCH] Remove invalid configuration in RequestMappingViewResolutionIntegrationTests Prior to this commit, RequestMappingViewResolutionIntegrationTests invoked the following: configurer.setTemplateLoaderPath( "classpath*:org/springframework/web/reactive/view/freemarker/"); However, that configuration is invalid since `classpath*:` is not supported for a `templateLoaderPath`. Despite that, the tests still passed since FreeMarkerConfigurer already registers a new ClassTemplateLoader(FreeMarkerConfigurer.class, ""), which automatically finds template files in the same package as FreeMarkerConfigurer (for the "spring.ftl" macro library support) and coincidentally RequestMappingViewResolutionIntegrationTests as well (which resides in the same package). This commit therefore removes the invalid configuration and adds a comment to explain what's going on. --- .../RequestMappingViewResolutionIntegrationTests.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingViewResolutionIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingViewResolutionIntegrationTests.java index eb0b9e4c1b9..266e492c6cb 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingViewResolutionIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingViewResolutionIntegrationTests.java @@ -111,10 +111,11 @@ class RequestMappingViewResolutionIntegrationTests extends AbstractRequestMappin @Bean public FreeMarkerConfigurer freeMarkerConfig() { - FreeMarkerConfigurer configurer = new FreeMarkerConfigurer(); - configurer.setPreferFileSystemAccess(false); - configurer.setTemplateLoaderPath("classpath*:org/springframework/web/reactive/view/freemarker/"); - return configurer; + // No need to configure a custom template loader path via setTemplateLoaderPath(), + // since FreeMarkerConfigurer already registers a + // new ClassTemplateLoader(FreeMarkerConfigurer.class, ""), which automatically + // finds template files in the same package as this test class. + return new FreeMarkerConfigurer(); } }