You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With XML configuration, setter selection can be random in case of overloaded setter methods (e.g. on SimpleClientHttpRequestFactory in 6.1.3 from convertForProperty method)
#32159
Closed
dima-sarin opened this issue
Jan 30, 2024
· 1 comment
Summary
In XMLConfig, if a bean-defined class has an overloaded setter, an exception may be thrown at runtime.
I checked the logs and found that the wrong setter was used.
Specifically, I found that the setter was changing each time the application was launched.
This behavior only occurs in XMLConfig and not in JavaConfig.
Detail
I found this behaviour in the bean definition of SimpleClientHttpRequestFactory.
Here is an example of a Bean definition.
SimplyClientHttpRequestFactory have overload setter of Duration and int such as setConnectTimeout method, setReadTimeout method.
In the XMLConfig example above, my expected behaviour was that a Duration setter would be used.
However, in actuality, the int setter was sometimes used.
According to stack trace the exception (TypeMismatchException) is happening here
jhoeller
changed the title
With XML configuration, setter selection can be random in case of overloaded setter methods (e.g. on SimpleClientHttpRequestFactory in 6.3 from convertForProperty method)
With XML configuration, setter selection can be random in case of overloaded setter methods (e.g. on SimpleClientHttpRequestFactory in 6.1.3 from convertForProperty method)
Jan 30, 2024
Affects: 6.1.3
Summary
In XMLConfig, if a bean-defined class has an overloaded setter, an exception may be thrown at runtime.
I checked the logs and found that the wrong setter was used.
Specifically, I found that the setter was changing each time the application was launched.
This behavior only occurs in XMLConfig and not in JavaConfig.
Detail
I found this behaviour in the bean definition of SimpleClientHttpRequestFactory.
Here is an example of a Bean definition.
SimplyClientHttpRequestFactory have overload setter of Duration and int such as setConnectTimeout method, setReadTimeout method.
https://github.com/spring-projects/spring-framework/blob/v6.1.0-M2/spring-web/src/main/java/org/springframework/http/client/SimpleClientHttpRequestFactory.java#L99C1-L135C3
In the XMLConfig example above, my expected behaviour was that a Duration setter would be used.
However, in actuality, the int setter was sometimes used.
According to stack trace the exception (TypeMismatchException) is happening here
spring-framework/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java
Line 1689 in 2e9d6a1
The fix by @jhoeller from #31872 will help if convertIfNecessary method is called later @
spring-framework/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java
Line 1717 in 2e9d6a1
Stack trace:
The text was updated successfully, but these errors were encountered: