[SPR-6807] ConversionService fails with CustomEditorConfigurer Created: 06/Feb/10  Updated: 19/Jun/12  Resolved: 07/Feb/10

Status: Closed
Project: Spring Framework
Component/s: None
Affects Version/s: 3.0 GA
Fix Version/s: 3.0.1

Type: Bug Priority: Major
Reporter: Dave Syer Assignee: Juergen Hoeller
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: 0d
Time Spent: Not Specified
Original Estimate: 0d

Issue Links:
Related
is related to SPR-6676 MapToMapConverter cannot handle unbou... Closed
Days since last comment: 7 years, 45 weeks, 4 days ago
Last commented by a User: false
Last updater: Trevor Marshall

 Description   

ConversionService fails with CustomEditorConfigurer. While it is not recommended to mix the two in the same context it is unavoidable if users want to use Spring Batch and a ConversionService (because Batch is 2.5.6 compatible and installs its own converter).

So if you install a CustomEditorConfigurer like this

	<bean id="customEditorConfigurer" class="org.springframework.beans.factory.config.CustomEditorConfigurer">
		<property name="customEditors">
			<map key-type="java.lang.String" value-type="java.lang.Class">
				<entry key="org.springframework.batch.item.file.transform.Range[]" value="org.springframework.batch.item.file.transform.RangeArrayPropertyEditor"/>
			</map>
		</property>
	</bean>

and then a ConversionService using the factory bean, you get an exception on startup saying that the ConversionService cannot convert the map in the CustomEditorConfigurer:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customEditorConfigurer' defined in file [....xml]: Initialization of bean failed; nested exception is org.springframework.core.convert.ConversionFailedException: Unable to convert value {org.springframework.batch.item.file.transform.Range[]=class org.springframework.batch.item.file.transform.RangeArrayPropertyEditor} from type 'java.util.LinkedHashMap' to type 'java.util.Map'; nested exception is java.lang.IllegalArgumentException: Left-hand side type must not be null
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1008)
	at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:604)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:398)
	at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:84)
	at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:1)
	at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:280)
	at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:304)
	... 24 more
Caused by: org.springframework.core.convert.ConversionFailedException: Unable to convert value {org.springframework.batch.item.file.transform.Range[]=class org.springframework.batch.item.file.transform.RangeArrayPropertyEditor} from type 'java.util.LinkedHashMap' to type 'java.util.Map'; nested exception is java.lang.IllegalArgumentException: Left-hand side type must not be null
	at org.springframework.core.convert.support.ConversionUtils.invokeConverter(ConversionUtils.java:40)
	at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:135)
	at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:199)
	at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:154)
	at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:452)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1351)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1310)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1067)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
	... 36 more
Caused by: java.lang.IllegalArgumentException: Left-hand side type must not be null
	at org.springframework.util.Assert.notNull(Assert.java:112)
	at org.springframework.util.ClassUtils.isAssignable(ClassUtils.java:806)
	at org.springframework.core.convert.TypeDescriptor.isTypeAssignableTo(TypeDescriptor.java:459)
	at org.springframework.core.convert.TypeDescriptor.isAssignableTo(TypeDescriptor.java:373)
	at org.springframework.core.convert.support.MapToMapConverter.convert(MapToMapConverter.java:81)
	at org.springframework.core.convert.support.ConversionUtils.invokeConverter(ConversionUtils.java:37)
	... 44 more



 Comments   
Comment by Juergen Hoeller [ 07/Feb/10 ]

Dave, this is basically the same issue as SPR-6676 - fixed for 3.0.1 already in recent snapshots.

Juergen

Generated at Thu Dec 14 21:03:43 UTC 2017 using JIRA 6.4.14#64029-sha1:ae256fe0fbb912241490ff1cecfb323ea0905ca5.