PropertySource implementations perform conversion to String arrays via StringUtils (getting rid of EMPTY_NAMES_ARRAY)

(cherry picked from commit b73c531)
This commit is contained in:
Juergen Hoeller
2014-08-22 00:09:53 +02:00
parent a4c8e6176c
commit 3e17331fd9
7 changed files with 26 additions and 21 deletions

View File

@@ -45,6 +45,7 @@ import org.springframework.util.Assert;
*/
public abstract class EnumerablePropertySource<T> extends PropertySource<T> {
@Deprecated
protected static final String[] EMPTY_NAMES_ARRAY = new String[0];
protected final Log logger = LogFactory.getLog(getClass());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2014 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.
@@ -18,6 +18,8 @@ package org.springframework.core.env;
import java.util.Map;
import org.springframework.util.StringUtils;
/**
* {@link PropertySource} that reads keys and values from a {@code Map} object.
*
@@ -38,7 +40,7 @@ public class MapPropertySource extends EnumerablePropertySource<Map<String, Obje
@Override
public String[] getPropertyNames() {
return this.source.keySet().toArray(EMPTY_NAMES_ARRAY);
return StringUtils.toStringArray(this.source.keySet());
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 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.
@@ -21,6 +21,7 @@ import java.util.LinkedList;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
@@ -66,7 +67,7 @@ public class MutablePropertySources implements PropertySources {
}
/**
* Create a new {@link MutablePropertySources} object and inheriting the given logger,
* Create a new {@link MutablePropertySources} object and inherit the given logger,
* usually from an enclosing {@link Environment}.
*/
MutablePropertySources(Log logger) {
@@ -127,7 +128,7 @@ public class MutablePropertySources implements PropertySources {
}
/**
* Add the given property source object with precedence immediately lower than
* Add the given property source object with precedence immediately lower
* than the named relative property source.
*/
public void addAfter(String relativePropertySourceName, PropertySource<?> propertySource) {
@@ -184,7 +185,7 @@ public class MutablePropertySources implements PropertySources {
}
@Override
public synchronized String toString() {
public String toString() {
String[] names = new String[this.size()];
for (int i=0; i < size(); i++) {
names[i] = this.propertySourceList.get(i).getName();
@@ -202,7 +203,7 @@ public class MutablePropertySources implements PropertySources {
}
/**
* Log the removal of the given propertySource if it is present.
* Remove the given property source if it is present.
*/
protected void removeIfPresent(PropertySource<?> propertySource) {
if (this.propertySourceList.contains(propertySource)) {