report error in case of constructor-arg index ambiguity (SPR-6329)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user