Shared DefaultConversionService instance for simple fallback purposes

Issue: SPR-14948
(cherry picked from commit 80931b2)
This commit is contained in:
Juergen Hoeller
2016-11-24 15:29:17 +01:00
parent 5ca10b1d67
commit a7ba63d425
7 changed files with 77 additions and 17 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,7 +44,7 @@ public class GenericMessageConverter extends SimpleMessageConverter {
* Create a new instance with a default {@link ConversionService}.
*/
public GenericMessageConverter() {
this.conversionService = new DefaultConversionService();
this.conversionService = DefaultConversionService.getSharedInstance();
}
/**

View File

@@ -76,7 +76,7 @@ public abstract class AbstractNamedValueMethodArgumentResolver implements Handle
* values are not expected to contain expressions
*/
protected AbstractNamedValueMethodArgumentResolver(ConversionService cs, ConfigurableBeanFactory beanFactory) {
this.conversionService = (cs != null ? cs : new DefaultConversionService());
this.conversionService = (cs != null ? cs : DefaultConversionService.getSharedInstance());
this.configurableBeanFactory = beanFactory;
this.expressionContext = (beanFactory != null ? new BeanExpressionContext(beanFactory, null) : null);
}
@@ -108,8 +108,7 @@ public abstract class AbstractNamedValueMethodArgumentResolver implements Handle
}
if (!ClassUtils.isAssignableValue(parameter.getParameterType(), arg)) {
arg = this.conversionService.convert(
arg, TypeDescriptor.valueOf(arg.getClass()), new TypeDescriptor(parameter));
arg = this.conversionService.convert(arg, TypeDescriptor.forObject(arg), new TypeDescriptor(parameter));
}
handleResolvedValue(arg, namedValueInfo.name, parameter, message);