Skip to content

Commit 914425e

Browse files
committed
Polishing
1 parent cd4ef6f commit 914425e

File tree

7 files changed

+32
-15
lines changed

7 files changed

+32
-15
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/config/YamlProcessor.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,16 +432,14 @@ public enum ResolutionMethod {
432432
/**
433433
* {@link Constructor} that supports filtering of unsupported types.
434434
* <p>If an unsupported type is encountered in a YAML document, an
435-
* {@link IllegalStateException} will be thrown from {@link #getClassForName(String)}.
436-
* @since 5.1.16
435+
* {@link IllegalStateException} will be thrown from {@link #getClassForName}.
437436
*/
438437
private class FilteringConstructor extends Constructor {
439438

440439
FilteringConstructor(LoaderOptions loaderOptions) {
441440
super(loaderOptions);
442441
}
443442

444-
445443
@Override
446444
protected Class<?> getClassForName(String name) throws ClassNotFoundException {
447445
Assert.state(YamlProcessor.this.supportedTypes.contains(name),

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -223,6 +223,9 @@ public String resolveRequiredPlaceholders(String text) throws IllegalArgumentExc
223223
* @see #setIgnoreUnresolvableNestedPlaceholders
224224
*/
225225
protected String resolveNestedPlaceholders(String value) {
226+
if (value.isEmpty()) {
227+
return value;
228+
}
226229
return (this.ignoreUnresolvableNestedPlaceholders ?
227230
resolvePlaceholders(value) : resolveRequiredPlaceholders(value));
228231
}

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -44,10 +44,20 @@
4444
*/
4545
public abstract class EnumerablePropertySource<T> extends PropertySource<T> {
4646

47+
/**
48+
* Create a new {@code EnumerablePropertySource} with the given name and source object.
49+
* @param name the associated name
50+
* @param source the source object
51+
*/
4752
public EnumerablePropertySource(String name, T source) {
4853
super(name, source);
4954
}
5055

56+
/**
57+
* Create a new {@code EnumerablePropertySource} with the given name and with a new
58+
* {@code Object} instance as the underlying source.
59+
* @param name the associated name
60+
*/
5161
protected EnumerablePropertySource(String name) {
5262
super(name);
5363
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -98,7 +98,6 @@ public interface PropertyResolver {
9898
* @return the resolved String (never {@code null})
9999
* @throws IllegalArgumentException if given text is {@code null}
100100
* @see #resolveRequiredPlaceholders
101-
* @see org.springframework.util.SystemPropertyUtils#resolvePlaceholders(String)
102101
*/
103102
String resolvePlaceholders(String text);
104103

@@ -109,7 +108,6 @@ public interface PropertyResolver {
109108
* @return the resolved String (never {@code null})
110109
* @throws IllegalArgumentException if given text is {@code null}
111110
* or if any placeholders are unresolvable
112-
* @see org.springframework.util.SystemPropertyUtils#resolvePlaceholders(String, boolean)
113111
*/
114112
String resolveRequiredPlaceholders(String text) throws IllegalArgumentException;
115113

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -68,6 +68,8 @@ public abstract class PropertySource<T> {
6868

6969
/**
7070
* Create a new {@code PropertySource} with the given name and source object.
71+
* @param name the associated name
72+
* @param source the source object
7173
*/
7274
public PropertySource(String name, T source) {
7375
Assert.hasText(name, "Property source name must contain at least one character");

spring-core/src/main/java/org/springframework/util/SystemPropertyUtils.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -78,6 +78,9 @@ public static String resolvePlaceholders(String text) {
7878
* and the "ignoreUnresolvablePlaceholders" flag is {@code false}
7979
*/
8080
public static String resolvePlaceholders(String text, boolean ignoreUnresolvablePlaceholders) {
81+
if (text.isEmpty()) {
82+
return text;
83+
}
8184
PropertyPlaceholderHelper helper = (ignoreUnresolvablePlaceholders ? nonStrictHelper : strictHelper);
8285
return helper.replacePlaceholders(text, new SystemPropertyPlaceholderResolver(text));
8386
}

spring-web/src/main/java/org/springframework/web/util/ServletContextPropertyUtils.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.web.util;
1718

1819
import javax.servlet.ServletContext;
@@ -73,16 +74,18 @@ public static String resolvePlaceholders(String text, ServletContext servletCont
7374
* @see SystemPropertyUtils#PLACEHOLDER_SUFFIX
7475
* @see SystemPropertyUtils#resolvePlaceholders(String, boolean)
7576
*/
76-
public static String resolvePlaceholders(String text, ServletContext servletContext,
77-
boolean ignoreUnresolvablePlaceholders) {
77+
public static String resolvePlaceholders(
78+
String text, ServletContext servletContext, boolean ignoreUnresolvablePlaceholders) {
7879

80+
if (text.isEmpty()) {
81+
return text;
82+
}
7983
PropertyPlaceholderHelper helper = (ignoreUnresolvablePlaceholders ? nonStrictHelper : strictHelper);
8084
return helper.replacePlaceholders(text, new ServletContextPlaceholderResolver(text, servletContext));
8185
}
8286

8387

84-
private static class ServletContextPlaceholderResolver
85-
implements PropertyPlaceholderHelper.PlaceholderResolver {
88+
private static class ServletContextPlaceholderResolver implements PropertyPlaceholderHelper.PlaceholderResolver {
8689

8790
private final String text;
8891

0 commit comments

Comments
 (0)