Browse Source

DATACMNS-1357 - Use shared DefaultConversionService in ProxyProjectionFactory and ResultProcessor.

ProxyProjectionFactory and ResultProcessor require a DefaultConversionService to convert values for projection proxies and to post-process query method results. Creating instances of these types requires an instance of the conversion service which previously created a DefaultConversionService instance (along all converter registrations) upon ProxyProjection/ResultProcessor instantiation.

We now use the shared instance that is initialized once and shared across all ProxyProjection/ResultProcessor instances to reduce garbage and improve the CPU profile.
pull/303/head
Mark Paluch 8 years ago
parent
commit
54b93f9e8c
  1. 3
      src/main/java/org/springframework/data/projection/ProxyProjectionFactory.java
  2. 2
      src/main/java/org/springframework/data/repository/query/ResultProcessor.java

3
src/main/java/org/springframework/data/projection/ProxyProjectionFactory.java

@ -41,6 +41,7 @@ import org.springframework.util.ConcurrentReferenceHashMap; @@ -41,6 +41,7 @@ import org.springframework.util.ConcurrentReferenceHashMap;
*
* @author Oliver Gierke
* @author Christoph Strobl
* @author Mark Paluch
* @see SpelAwareProxyProjectionFactory
* @since 1.10
*/
@ -60,7 +61,7 @@ class ProxyProjectionFactory implements ProjectionFactory, BeanClassLoaderAware @@ -60,7 +61,7 @@ class ProxyProjectionFactory implements ProjectionFactory, BeanClassLoaderAware
this.factories.add(MapAccessingMethodInterceptorFactory.INSTANCE);
this.factories.add(PropertyAccessingMethodInvokerFactory.INSTANCE);
this.conversionService = new DefaultConversionService();
this.conversionService = DefaultConversionService.getSharedInstance();
}
/*

2
src/main/java/org/springframework/data/repository/query/ResultProcessor.java

@ -260,7 +260,7 @@ public class ResultProcessor { @@ -260,7 +260,7 @@ public class ResultProcessor {
* @param factory must not be {@literal null}.
*/
ProjectingConverter(ReturnedType type, ProjectionFactory factory) {
this(type, factory, new DefaultConversionService());
this(type, factory, DefaultConversionService.getSharedInstance());
}
/**

Loading…
Cancel
Save