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

@@ -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.
@@ -20,7 +20,7 @@ import javax.servlet.ServletConfig;
import org.springframework.core.env.EnumerablePropertySource;
import org.springframework.core.env.PropertySource;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
/**
* {@link PropertySource} that reads init parameters from a {@link ServletConfig} object.
@@ -37,8 +37,7 @@ public class ServletConfigPropertySource extends EnumerablePropertySource<Servle
@Override
public String[] getPropertyNames() {
return CollectionUtils.toArray(
this.source.getInitParameterNames(), EMPTY_NAMES_ARRAY);
return StringUtils.toStringArray(this.source.getInitParameterNames());
}
@Override

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.
@@ -20,7 +20,7 @@ import javax.servlet.ServletContext;
import org.springframework.core.env.EnumerablePropertySource;
import org.springframework.core.env.PropertySource;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
/**
* {@link PropertySource} that reads init parameters from a {@link ServletContext} object.
@@ -37,12 +37,12 @@ public class ServletContextPropertySource extends EnumerablePropertySource<Servl
@Override
public String[] getPropertyNames() {
return CollectionUtils.toArray(
this.source.getInitParameterNames(), EMPTY_NAMES_ARRAY);
return StringUtils.toStringArray(this.source.getInitParameterNames());
}
@Override
public String getProperty(String name) {
return this.source.getInitParameter(name);
}
}