From 640000c0bb4328f1b6c271f63b135d466fd2fdc0 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 24 Aug 2020 18:21:36 +0200 Subject: [PATCH] Disable file system preference for Freemarker templates Previously to this commit, a project that has several classpath locations matching the template path may lead to some of those locations to be ignored if one of them is a directory. This can easily happen if you run your tests in your IDE. This commit changes the default of "preferFileSystemAccess" to false so that the complete classpath is always considered. Closes gh-23051 --- .../autoconfigure/freemarker/FreeMarkerProperties.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerProperties.java index be5e7eb62a..466bce2343 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,10 +49,12 @@ public class FreeMarkerProperties extends AbstractTemplateViewResolverProperties private String[] templateLoaderPath = new String[] { DEFAULT_TEMPLATE_LOADER_PATH }; /** - * Whether to prefer file system access for template loading. File system access - * enables hot detection of template changes. + * Whether to prefer file system access for template loading to enables hot detection + * of template changes. When a template path is detected as a directory, templates are + * loaded from the directory only and other matching classpath locations will not be + * considered. */ - private boolean preferFileSystemAccess = true; + private boolean preferFileSystemAccess; public FreeMarkerProperties() { super(DEFAULT_PREFIX, DEFAULT_SUFFIX);