Skip to content

Commit f29b791

Browse files
jhoellerunknown
authored andcommitted
MutablePropertySources log statements guarded by isDebugEnabled
Issue: SPR-9670
1 parent a90f256 commit f29b791

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

spring-core/src/main/java/org/springframework/core/env/MutablePropertySources.java

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,10 @@ public Iterator<PropertySource<?>> iterator() {
9191
* Add the given property source object with highest precedence.
9292
*/
9393
public void addFirst(PropertySource<?> propertySource) {
94-
logger.debug(String.format("Adding [%s] PropertySource with highest search precedence",
95-
propertySource.getName()));
94+
if (logger.isDebugEnabled()) {
95+
logger.debug(String.format("Adding [%s] PropertySource with highest search precedence",
96+
propertySource.getName()));
97+
}
9698
removeIfPresent(propertySource);
9799
this.propertySourceList.addFirst(propertySource);
98100
}
@@ -101,8 +103,10 @@ public void addFirst(PropertySource<?> propertySource) {
101103
* Add the given property source object with lowest precedence.
102104
*/
103105
public void addLast(PropertySource<?> propertySource) {
104-
logger.debug(String.format("Adding [%s] PropertySource with lowest search precedence",
105-
propertySource.getName()));
106+
if (logger.isDebugEnabled()) {
107+
logger.debug(String.format("Adding [%s] PropertySource with lowest search precedence",
108+
propertySource.getName()));
109+
}
106110
removeIfPresent(propertySource);
107111
this.propertySourceList.addLast(propertySource);
108112
}
@@ -112,8 +116,10 @@ public void addLast(PropertySource<?> propertySource) {
112116
* than the named relative property source.
113117
*/
114118
public void addBefore(String relativePropertySourceName, PropertySource<?> propertySource) {
115-
logger.debug(String.format("Adding [%s] PropertySource with search precedence immediately higher than [%s]",
116-
propertySource.getName(), relativePropertySourceName));
119+
if (logger.isDebugEnabled()) {
120+
logger.debug(String.format("Adding [%s] PropertySource with search precedence immediately higher than [%s]",
121+
propertySource.getName(), relativePropertySourceName));
122+
}
117123
assertLegalRelativeAddition(relativePropertySourceName, propertySource);
118124
removeIfPresent(propertySource);
119125
int index = assertPresentAndGetIndex(relativePropertySourceName);
@@ -125,8 +131,10 @@ public void addBefore(String relativePropertySourceName, PropertySource<?> prope
125131
* than the named relative property source.
126132
*/
127133
public void addAfter(String relativePropertySourceName, PropertySource<?> propertySource) {
128-
logger.debug(String.format("Adding [%s] PropertySource with search precedence immediately lower than [%s]",
129-
propertySource.getName(), relativePropertySourceName));
134+
if (logger.isDebugEnabled()) {
135+
logger.debug(String.format("Adding [%s] PropertySource with search precedence immediately lower than [%s]",
136+
propertySource.getName(), relativePropertySourceName));
137+
}
130138
assertLegalRelativeAddition(relativePropertySourceName, propertySource);
131139
removeIfPresent(propertySource);
132140
int index = assertPresentAndGetIndex(relativePropertySourceName);
@@ -145,7 +153,9 @@ public int precedenceOf(PropertySource<?> propertySource) {
145153
* @param name the name of the property source to find and remove
146154
*/
147155
public PropertySource<?> remove(String name) {
148-
logger.debug(String.format("Removing [%s] PropertySource", name));
156+
if (logger.isDebugEnabled()) {
157+
logger.debug(String.format("Removing [%s] PropertySource", name));
158+
}
149159
int index = this.propertySourceList.indexOf(PropertySource.named(name));
150160
return index == -1 ? null : this.propertySourceList.remove(index);
151161
}
@@ -158,8 +168,10 @@ public PropertySource<?> remove(String name) {
158168
* @see #contains
159169
*/
160170
public void replace(String name, PropertySource<?> propertySource) {
161-
logger.debug(String.format("Replacing [%s] PropertySource with [%s]",
162-
name, propertySource.getName()));
171+
if (logger.isDebugEnabled()) {
172+
logger.debug(String.format("Replacing [%s] PropertySource with [%s]",
173+
name, propertySource.getName()));
174+
}
163175
int index = assertPresentAndGetIndex(name);
164176
this.propertySourceList.set(index, propertySource);
165177
}

0 commit comments

Comments
 (0)