<bean id="someProxyServerBuilder" class="org.asynchttpclient.proxy.ProxyServer.Builder">
<property name="realm">
<bean factory-bean="someRealmBuilder" factory-method="build"/>
</property>
</bean>
<bean id="someRealmBuilder" class="org.asynchttpclient.Realm.Builder">
</bean>
This configuration works successfully in Spring 5.x, but fails with Spring 6.x with the following error:
Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'org.asynchttpclient.Realm' to required type 'org.asynchttpclient.Realm$Builder' for property 'realm'; Cannot convert value of type 'org.asynchttpclient.Realm' to required type 'org.asynchttpclient.Realm$Builder' for property 'realm': no matching editors or conversion strategy found
at org.springframework.beans.AbstractNestablePropertyAccessor.convertIfNecessary(AbstractNestablePropertyAccessor.java:594)
at org.springframework.beans.AbstractNestablePropertyAccessor.convertForProperty(AbstractNestablePropertyAccessor.java:608)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:190)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1728)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1685)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1429)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595)
... 107 more
Caused by: java.lang.IllegalStateException: Cannot convert value of type 'org.asynchttpclient.Realm' to required type 'org.asynchttpclient.Realm$Builder' for property 'realm': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:260)
at org.springframework.beans.AbstractNestablePropertyAccessor.convertIfNecessary(AbstractNestablePropertyAccessor.java:589)
... 113 more
The complexity comes from the fact that org.asynchttpclient.proxy.ProxyServer.Builder#setRealm
is overloaded, and there are two versions—one accepting Realm
and another accepting Realm$Builder
.
The following code in BeanWrapperImpl
seems like it's not considering there may be several property descriptors for the same name:
https://github.com/spring-projects/spring-framework/blob/2e57603/spring-beans/src/main/java/org/springframework/beans/BeanWrapperImpl.java#L184
PropertyDescriptor pd = cachedIntrospectionResults.getPropertyDescriptor(propertyName);
What makes the matter worse, looks like the behavior is not deterministic. In different environments Spring will try to use different setters.
Comment From: jhoeller
Which version have you tried this with specifically? As of 6.1.4, there is a dedicated write method fallback mechanism that should cover such overloaded setter scenarios: see #31872 and #32159.
Comment From: Spikhalskiy
@jhoeller it's 6.0.23; we are making baby steps in migrating from Spring 5. Taking into account that 6.0 is EOL, I will reopen if the issue I still present on the latest 6.1. Thank you for the context!