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

This commit is contained in:
Juergen Hoeller 2009-11-12 16:22:42 +00:00
parent d66fd9843e
commit 5d772554ae
2 changed files with 14 additions and 1 deletions

View File

@ -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

View File

@ -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();