Add JSR310 converters to the converters used for projections.

Similar converters where removed because they clashed with the support for nullable wrappers. This adds them back as dedicated converters that does not clash with conversions for nullable wrappers.

See bd3992dfc5 (diff-96f7084777a2a702d85f5c600e542b10123d6c3332ed3d3f8e329ca7061faab0R55)

Original Pull Request: #479
Closes: #2223
This commit is contained in:
Jens Schauder
2020-12-07 15:10:03 +01:00
committed by Christoph Strobl
parent efe93e31b1
commit dc09d5d34d
2 changed files with 61 additions and 8 deletions

View File

@@ -28,6 +28,7 @@ import org.springframework.aop.framework.ProxyFactory;
import org.springframework.beans.factory.BeanClassLoaderAware;
import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.core.convert.support.GenericConversionService;
import org.springframework.data.convert.Jsr310Converters;
import org.springframework.data.util.NullableWrapperConverters;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
@@ -43,6 +44,7 @@ import org.springframework.util.ConcurrentReferenceHashMap;
* @author Oliver Gierke
* @author Christoph Strobl
* @author Mark Paluch
* @author Jens Schauder
* @see SpelAwareProxyProjectionFactory
* @since 1.10
*/
@@ -51,6 +53,7 @@ class ProxyProjectionFactory implements ProjectionFactory, BeanClassLoaderAware
final static GenericConversionService CONVERSION_SERVICE = new DefaultConversionService();
static {
Jsr310Converters.getConvertersToRegister().forEach(CONVERSION_SERVICE::addConverter);
NullableWrapperConverters.registerConvertersIn(CONVERSION_SERVICE);
CONVERSION_SERVICE.removeConvertible(Object.class, Object.class);
}