Respect <description> within <entry> per beans XSD

Prior to this change, a parsing exception would be thrown if a
<description> element was placed within a <map><entry/></map>
element. The beans XSD has always permitted this arrangement,
but BeanDefinitionParserDelegate did not respect it. The latter now
simply ignores any <description> element, rather than failing.

Issue: SPR-8563
This commit is contained in:
Chris Beams
2011-07-28 02:21:22 +00:00
parent f432f3043f
commit 226256e264
2 changed files with 16 additions and 1 deletions

View File

@@ -1255,7 +1255,10 @@ public class BeanDefinitionParserDelegate {
}
else {
// Child element is what we're looking for.
if (valueEle != null) {
if (nodeNameEquals(candidateEle, DESCRIPTION_ELEMENT)) {
// the element is a <description> -> ignore it
}
else if (valueEle != null) {
error("<entry> element must not contain more than one value sub-element", entryEle);
}
else {

View File

@@ -155,6 +155,18 @@
</property>
</bean>
<!-- The <description> element below caused parsing exception prior to resolution of SPR-8563 -->
<bean id="mapWithDescriptionInEntry" class="org.springframework.beans.factory.xml.HasMap">
<property name="map">
<map>
<entry key="e1">
<description>A map entry with a description</description>
<value>v1</value>
</entry>
</map>
</property>
</bean>
<bean id="fooKey" class="java.lang.String">
<constructor-arg value="foo"/>
</bean>