CompositePropertySource rejects getPropertyNames call when containing a non-enumerable source

Issue: SPR-12788
This commit is contained in:
Juergen Hoeller 2015-03-05 18:53:25 +01:00
parent f786fc3226
commit 7e8ffc7bf5
1 changed files with 5 additions and 3 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2015 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.
@ -78,9 +78,11 @@ public class CompositePropertySource extends EnumerablePropertySource<Object> {
public String[] getPropertyNames() {
Set<String> names = new LinkedHashSet<String>();
for (PropertySource<?> propertySource : this.propertySources) {
if (propertySource instanceof EnumerablePropertySource) {
names.addAll(Arrays.asList(((EnumerablePropertySource<?>) propertySource).getPropertyNames()));
if (!(propertySource instanceof EnumerablePropertySource)) {
throw new IllegalStateException(
"Failed to enumerate property names due to non-enumerable property source: " + propertySource);
}
names.addAll(Arrays.asList(((EnumerablePropertySource<?>) propertySource).getPropertyNames()));
}
return StringUtils.toStringArray(names);
}