In Bean definition by XMLConfig, class constructor selection may be random #31871
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
status: invalid
An issue that we don't feel is valid
Affects: version 6.1.0-M3 or later
Summary
In XMLConfig, if a bean-defined class has an overloaded constructor, an exception may occur at runtime.
I checked the logs and found that the wrong constructor was used.
This behavior seems to occur when only the name attribute is used on the constructor-arg element.
It does not occur when the type or index attribute is used on the constructor-arg element.
Detail
I found this behavior in the bean definition of RestTemplate.
Here is an example of a Baen definition that throws an exception.
I was expecting
HttpHost(final String hostname, final int port)
to be used in the above example.
But actuality
HttpHost(final String scheme, final String hostname)
was used.
https://github.com/apache/httpcomponents-core/blob/master/httpcore5/src/main/java/org/apache/hc/core5/http/HttpHost.java#L118-L135
The log of that case is shown below.
log.txt
On the other hand, when I wrote a bean definition with the type attribute
HttpHost(final String hostname, final int port)
is used.
I think that within the constructor-arg element, the name attribute has not worked version 6.1.0-M3 or later.
Is this a Spring Framework spec change or a bug?
The text was updated successfully, but these errors were encountered: