Skip to content

Commit ea8cf8c

Browse files
committed
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.
1 parent 31a0825 commit ea8cf8c

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
*
4242
* @author Oliver Gierke
4343
* @author Christoph Strobl
44+
* @author Mark Paluch
4445
* @see SpelAwareProxyProjectionFactory
4546
* @since 1.10
4647
*/
@@ -60,7 +61,7 @@ protected ProxyProjectionFactory() {
6061
this.factories.add(MapAccessingMethodInterceptorFactory.INSTANCE);
6162
this.factories.add(PropertyAccessingMethodInvokerFactory.INSTANCE);
6263

63-
this.conversionService = new DefaultConversionService();
64+
this.conversionService = DefaultConversionService.getSharedInstance();
6465
}
6566

6667
/*

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ private static class ProjectingConverter implements Converter<Object, Object> {
260260
* @param factory must not be {@literal null}.
261261
*/
262262
ProjectingConverter(ReturnedType type, ProjectionFactory factory) {
263-
this(type, factory, new DefaultConversionService());
263+
this(type, factory, DefaultConversionService.getSharedInstance());
264264
}
265265

266266
/**

0 commit comments

Comments
 (0)