Commit c567bdd2 authored by Jason Song's avatar Jason Song

fix for Spring 4.1.2 that composite property source should extend EnumerablePropertySource

parent 6015c757
package com.ctrip.framework.apollo.spring.config; package com.ctrip.framework.apollo.spring.config;
import com.ctrip.framework.apollo.Config; import java.util.Set;
import org.springframework.core.env.EnumerablePropertySource;
import org.springframework.core.env.PropertySource; import com.ctrip.framework.apollo.Config;
/** /**
* Property source wrapper for Config * Property source wrapper for Config
* *
* @author Jason Song(song_s@ctrip.com) * @author Jason Song(song_s@ctrip.com)
*/ */
public class ConfigPropertySource extends PropertySource<Config> { public class ConfigPropertySource extends EnumerablePropertySource<Config> {
private static final String[] EMPTY_ARRAY = new String[0];
public ConfigPropertySource(String name, Config source) { public ConfigPropertySource(String name, Config source) {
super(name, source); super(name, source);
} }
@Override
public String[] getPropertyNames() {
Set<String> propertyNames = this.source.getPropertyNames();
if (propertyNames.isEmpty()) {
return EMPTY_ARRAY;
}
return propertyNames.toArray(new String[propertyNames.size()]);
}
@Override @Override
public Object getProperty(String name) { public Object getProperty(String name) {
return this.source.getProperty(name, null); return this.source.getProperty(name, null);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment