From 7e8ffc7bf56dcc9d7fcc3992589b126b0eecf22f Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 5 Mar 2015 18:53:25 +0100 Subject: [PATCH] CompositePropertySource rejects getPropertyNames call when containing a non-enumerable source Issue: SPR-12788 --- .../springframework/core/env/CompositePropertySource.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/env/CompositePropertySource.java b/spring-core/src/main/java/org/springframework/core/env/CompositePropertySource.java index 07ddbaed6a..8591360229 100644 --- a/spring-core/src/main/java/org/springframework/core/env/CompositePropertySource.java +++ b/spring-core/src/main/java/org/springframework/core/env/CompositePropertySource.java @@ -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 { public String[] getPropertyNames() { Set names = new LinkedHashSet(); 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); }