parent
6c7a5c5077
commit
7dc9bddf9a
|
@ -79,7 +79,7 @@ class DefaultPropertyNamePatternsMatcher implements PropertyNamePatternsMatcher
|
|||
}
|
||||
else {
|
||||
char charAfter = propertyNameChars[this.names[nameIndex].length()];
|
||||
if (isDelimeter(charAfter)) {
|
||||
if (isDelimiter(charAfter)) {
|
||||
match[nameIndex] = true;
|
||||
noneMatched = false;
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ class DefaultPropertyNamePatternsMatcher implements PropertyNamePatternsMatcher
|
|||
return c1 == c2;
|
||||
}
|
||||
|
||||
private boolean isDelimeter(char c) {
|
||||
private boolean isDelimiter(char c) {
|
||||
for (char delimiter : this.delimiters) {
|
||||
if (c == delimiter) {
|
||||
return true;
|
||||
|
|
|
@ -53,9 +53,9 @@ import org.springframework.validation.Validator;
|
|||
public class PropertiesConfigurationFactory<T> implements FactoryBean<T>,
|
||||
MessageSourceAware, InitializingBean {
|
||||
|
||||
private static final char[] EXACT_DELIMETERS = { '_', '.', '[' };
|
||||
private static final char[] EXACT_DELIMITERS = { '_', '.', '[' };
|
||||
|
||||
private static final char[] TARGET_NAME_DELIMETERS = { '_', '.' };
|
||||
private static final char[] TARGET_NAME_DELIMITERS = { '_', '.' };
|
||||
|
||||
private final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
|
@ -308,13 +308,13 @@ public class PropertiesConfigurationFactory<T> implements FactoryBean<T>,
|
|||
if (this.ignoreUnknownFields && !isMapTarget()) {
|
||||
// Since unknown fields are ignored we can filter them out early to save
|
||||
// unnecessary calls to the PropertySource.
|
||||
return new DefaultPropertyNamePatternsMatcher(EXACT_DELIMETERS, true, names);
|
||||
return new DefaultPropertyNamePatternsMatcher(EXACT_DELIMITERS, true, names);
|
||||
}
|
||||
if (this.targetName != null) {
|
||||
// We can filter properties to those starting with the target name, but
|
||||
// we can't do a complete filter since we need to trigger the
|
||||
// unknown fields check
|
||||
return new DefaultPropertyNamePatternsMatcher(TARGET_NAME_DELIMETERS,
|
||||
return new DefaultPropertyNamePatternsMatcher(TARGET_NAME_DELIMITERS,
|
||||
this.targetName);
|
||||
}
|
||||
// Not ideal, we basically can't filter anything
|
||||
|
|
|
@ -62,7 +62,7 @@ public class PropertySourcesPropertyValues implements PropertyValues {
|
|||
* @param propertySources a PropertySources instance
|
||||
* @param includePatterns property name patterns to include from system properties and
|
||||
* environment variables
|
||||
* @param propertyNames the property names to used in lieu of an
|
||||
* @param propertyNames the property names to use in lieu of an
|
||||
* {@link EnumerablePropertySource}.
|
||||
*/
|
||||
public PropertySourcesPropertyValues(PropertySources propertySources,
|
||||
|
@ -74,7 +74,7 @@ public class PropertySourcesPropertyValues implements PropertyValues {
|
|||
/**
|
||||
* Create a new PropertyValues from the given PropertySources
|
||||
* @param propertySources a PropertySources instance
|
||||
* @param propertyNames the property names to used in lieu of an
|
||||
* @param propertyNames the property names to use in lieu of an
|
||||
* {@link EnumerablePropertySource}.
|
||||
* @param includes the property name patterns to include
|
||||
*/
|
||||
|
|
|
@ -69,9 +69,9 @@ public class DefaultPropertyNamePatternsMatcherTests {
|
|||
|
||||
@Test
|
||||
public void withSquareBrackets() throws Exception {
|
||||
char[] delimeters = "._[".toCharArray();
|
||||
char[] delimiters = "._[".toCharArray();
|
||||
PropertyNamePatternsMatcher matcher = new DefaultPropertyNamePatternsMatcher(
|
||||
delimeters, "aaa", "bbbb", "ccccc");
|
||||
delimiters, "aaa", "bbbb", "ccccc");
|
||||
assertTrue(matcher.matches("bbbb"));
|
||||
assertTrue(matcher.matches("bbbb[4]"));
|
||||
assertFalse(matcher.matches("bbb[4]"));
|
||||
|
|
Loading…
Reference in New Issue