Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
fmbenhassine opened this issue Oct 17, 2022 · 2 comments · Fixed by #320
Closed

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

fmbenhassine opened this issue Oct 17, 2022 · 2 comments · Fixed by #320
Assignees
Labels
Milestone

Comments

@fmbenhassine
Copy link

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

@garyrussell garyrussell self-assigned this Oct 17, 2022
@garyrussell garyrussell added this to the 2.0.0-RC2 milestone Oct 17, 2022
garyrussell added a commit to garyrussell/spring-retry that referenced this issue Oct 17, 2022
Resolves spring-projects#319

Regression: spring-projects@47c1e52

Multiple setters with different types.
@garyrussell
Copy link
Contributor

PR submitted @fmbenhassine can you test with the snapshot after @artembilan merges.

If all ok, @snicoll would you mind building an RC2 for @fmbenhassine ? Thanks

Sorry for the inconvenience; I guess we were just unlucky this wasn't discovered earlier.

artembilan pushed a commit that referenced this issue Oct 17, 2022
Resolves #319

Regression: 47c1e52

Multiple setters with different types.
@fmbenhassine
Copy link
Author

PR submitted @fmbenhassine can you test with the snapshot after @artembilan merges.

The Batch build passes with this fix in the latest snapshots. Thank you for the follow up and for the quick fix!

@snicoll snicoll added the bug label Oct 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants