Skip to content

Improve error message when mixing positional/named constructor arguments across parent/child beans #29976

Closed as not planned
@scantor

Description

@scantor

This is probably intentional behavior, or at least "not accommodated", but just in case...

I ran into a case where using a child and parent in combination broke because I hadn't noted that my parent bean specified the first argument by ordinal, and then I inadvertently specified all three constructor arguments by name in the child bean. This caused the instantiation to fail with a generic "can't find matching constructor" exception message.

For example:

<bean id="theParent" class="....something" c:_0="arg" />

<bean id="theChild" parent="theParent" c:arg1="arg" c:arg2="arg" c:arg3="arg" />

I would guess it's too much hassle and probably somewhat of a combinatorial explosion to expect this to work, but I guess it might be nice to have a more specific error message if the problem occurs and it notices there are arguments on both perhaps.

Close if this is intentional obviously.

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: supersededAn issue that has been superseded by anothertype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions