From 9faa53cae40d77206034f0e1e1dcec6b8e373f73 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Thu, 21 Nov 2024 10:44:50 +0100 Subject: [PATCH] Revise PartTree query caching. See #3588 Original pull request: #3653 --- .../repository/query/JpqlQueryBuilder.java | 2 +- .../repository/query/PartTreeJpaQuery.java | 21 +++++++------------ .../repository/query/PartTreeQueryCache.java | 5 +++-- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpqlQueryBuilder.java b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpqlQueryBuilder.java index db6697a9d5..287b397384 100644 --- a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpqlQueryBuilder.java +++ b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpqlQueryBuilder.java @@ -450,7 +450,7 @@ default Select instantiate(Class resultType, Collection cache = new LinkedHashMap<>() { + private final Map cache = Collections.synchronizedMap(new LinkedHashMap<>() { @Override protected boolean removeEldestEntry(Map.Entry eldest) { return size() > 256; } - }; + }); @Nullable JpqlQueryCreator get(Sort sort, JpaParametersParameterAccessor accessor) {