Browse Source

report error in case of constructor-arg index ambiguity (SPR-6329)

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@2404 50f2f4bb-b051-0410-bef5-90022cba6387
pull/1/head
Juergen Hoeller 16 years ago
parent
commit
997c3dcc75
  1. 8
      org.springframework.beans/src/main/java/org/springframework/beans/factory/config/ConstructorArgumentValues.java
  2. 7
      org.springframework.beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionParserDelegate.java

8
org.springframework.beans/src/main/java/org/springframework/beans/factory/config/ConstructorArgumentValues.java

@ -131,6 +131,14 @@ public class ConstructorArgumentValues { @@ -131,6 +131,14 @@ public class ConstructorArgumentValues {
this.indexedArgumentValues.put(key, newValue);
}
/**
* Check whether an argument value has been registered for the given index.
* @param index the index in the constructor argument list
*/
public boolean hasIndexedArgumentValue(int index) {
return this.indexedArgumentValues.containsKey(index);
}
/**
* Get argument value for the given index in the constructor argument list.
* @param index the index in the constructor argument list

7
org.springframework.beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionParserDelegate.java

@ -778,7 +778,12 @@ public class BeanDefinitionParserDelegate { @@ -778,7 +778,12 @@ public class BeanDefinitionParserDelegate {
valueHolder.setName(nameAttr);
}
valueHolder.setSource(extractSource(ele));
bd.getConstructorArgumentValues().addIndexedArgumentValue(index, valueHolder);
if (bd.getConstructorArgumentValues().hasIndexedArgumentValue(index)) {
error("Ambiguous constructor-arg entries for index " + index, ele);
}
else {
bd.getConstructorArgumentValues().addIndexedArgumentValue(index, valueHolder);
}
}
finally {
this.parseState.pop();

Loading…
Cancel
Save