Skip to content

Unable to define a SimpleRetryPolicy bean with custom maxAttempts value in XML #319

@fmbenhassine

Description

@fmbenhassine

Defining a SimpleRetryPolicy bean in XML like follows:

<bean class="org.springframework.retry.policy.SimpleRetryPolicy" xmlns="http://www.springframework.org/schema/beans">
   <property name="maxAttempts" value="2" />
</bean>

fails with the following exception with the latest spring retry and spring framework snapshots:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.retry.policy.SimpleRetryPolicy#21590b35' defined in class path resource [org/springframework/batch/core/configuration/xml/ChunkElementRetryPolicyParserTests-context.xml]: Failed to convert property value of type 'java.lang.String' to required type 'java.util.function.Supplier' for property 'maxAttempts'; Cannot convert value of type 'java.lang.String' to required type 'java.util.function.Supplier' for property 'maxAttempts': no matching editors or conversion strategy found
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:606)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:521)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBeanValue(BeanDefinitionValueResolver.java:407)
	... 101 more
Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.lang.String' to required type 'java.util.function.Supplier' for property 'maxAttempts'; Cannot convert value of type 'java.lang.String' to required type 'java.util.function.Supplier' for property 'maxAttempts': 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:1713)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1670)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1414)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:598)
	... 103 more
Caused by: java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type 'java.util.function.Supplier' for property 'maxAttempts': no matching editors or conversion strategy found
	at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:262)
	at org.springframework.beans.AbstractNestablePropertyAccessor.convertIfNecessary(AbstractNestablePropertyAccessor.java:589)
	... 109 more

Could this be related to a recent change in SF with regard to property setting?

To give a bit of context, some tests in Batch started failing recently with that exception, like the following test: https://github.com/spring-projects/spring-batch/blob/main/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/ChunkElementRetryPolicyParserTests-context.xml

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions