Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
64f9d8d4
Commit
64f9d8d4
authored
Mar 22, 2021
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deprecate support for Mustache's Environment fallback
Closes gh-21045
parent
2dd4010e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
3 deletions
+20
-3
MustacheAutoConfiguration.java
...oot/autoconfigure/mustache/MustacheAutoConfiguration.java
+2
-1
MustacheEnvironmentCollector.java
.../autoconfigure/mustache/MustacheEnvironmentCollector.java
+18
-2
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheAutoConfiguration.java
View file @
64f9d8d4
/*
* Copyright 2012-202
0
the original author or authors.
* Copyright 2012-202
1
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.
...
...
@@ -75,6 +75,7 @@ public class MustacheAutoConfiguration {
return
Mustache
.
compiler
().
withLoader
(
mustacheTemplateLoader
).
withCollector
(
collector
(
environment
));
}
@Deprecated
private
Collector
collector
(
Environment
environment
)
{
MustacheEnvironmentCollector
collector
=
new
MustacheEnvironmentCollector
();
collector
.
setEnvironment
(
environment
);
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheEnvironmentCollector.java
View file @
64f9d8d4
/*
* Copyright 2012-202
0
the original author or authors.
* Copyright 2012-202
1
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.
...
...
@@ -16,9 +16,13 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
mustache
;
import
java.util.concurrent.atomic.AtomicBoolean
;
import
com.samskivert.mustache.DefaultCollector
;
import
com.samskivert.mustache.Mustache.Collector
;
import
com.samskivert.mustache.Mustache.VariableFetcher
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.springframework.context.EnvironmentAware
;
import
org.springframework.core.env.ConfigurableEnvironment
;
...
...
@@ -30,7 +34,10 @@ import org.springframework.core.env.Environment;
* @author Dave Syer
* @author Madhura Bhave
* @since 1.2.2
* @deprecated since 2.5.0 in favour of direct addition of values from the Environment to
* the model
*/
@Deprecated
public
class
MustacheEnvironmentCollector
extends
DefaultCollector
implements
EnvironmentAware
{
private
ConfigurableEnvironment
environment
;
...
...
@@ -56,9 +63,18 @@ public class MustacheEnvironmentCollector extends DefaultCollector implements En
private
class
PropertyVariableFetcher
implements
VariableFetcher
{
private
final
Log
log
=
LogFactory
.
getLog
(
PropertyVariableFetcher
.
class
);
private
final
AtomicBoolean
logDeprecationWarning
=
new
AtomicBoolean
();
@Override
public
Object
get
(
Object
ctx
,
String
name
)
{
return
MustacheEnvironmentCollector
.
this
.
environment
.
getProperty
(
name
);
String
property
=
MustacheEnvironmentCollector
.
this
.
environment
.
getProperty
(
name
);
if
(
property
!=
null
&&
this
.
logDeprecationWarning
.
compareAndSet
(
false
,
true
))
{
this
.
log
.
warn
(
"Mustache variable resolution relied upon deprecated support for falling back to the "
+
"Spring Environment. Please add values from the Environment directly to the model instead."
);
}
return
property
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment