Skip to content

Commit 9929d75

Browse files
committed
Adapt to Spring Framework convention for static cache field names
See gh-23345
1 parent 5e61e33 commit 9929d75

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

spring-orm/src/main/java/org/springframework/orm/jpa/ExtendedEntityManagerCreator.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -75,7 +75,8 @@
7575
*/
7676
public abstract class ExtendedEntityManagerCreator {
7777

78-
private static final Map<Class<?>, Class[]> CACHED_ENTITY_MANAGER_INTERFACES = new ConcurrentReferenceHashMap<>();
78+
private static final Map<Class<?>, Class<?>[]> cachedEntityManagerInterfaces = new ConcurrentReferenceHashMap<>(4);
79+
7980

8081
/**
8182
* Create an application-managed extended EntityManager proxy.
@@ -226,18 +227,18 @@ private static EntityManager createProxy(
226227
boolean containerManaged, boolean synchronizedWithTransaction) {
227228

228229
Assert.notNull(rawEm, "EntityManager must not be null");
229-
Class[] interfaces;
230+
Class<?>[] interfaces;
230231

231232
if (emIfc != null) {
232-
interfaces = CACHED_ENTITY_MANAGER_INTERFACES.computeIfAbsent(emIfc, key -> {
233+
interfaces = cachedEntityManagerInterfaces.computeIfAbsent(emIfc, key -> {
233234
Set<Class<?>> ifcs = new LinkedHashSet<>();
234235
ifcs.add(key);
235236
ifcs.add(EntityManagerProxy.class);
236237
return ClassUtils.toClassArray(ifcs);
237238
});
238239
}
239240
else {
240-
interfaces = CACHED_ENTITY_MANAGER_INTERFACES.computeIfAbsent(rawEm.getClass(), key -> {
241+
interfaces = cachedEntityManagerInterfaces.computeIfAbsent(rawEm.getClass(), key -> {
241242
Set<Class<?>> ifcs = new LinkedHashSet<>();
242243
ifcs.addAll(ClassUtils
243244
.getAllInterfacesForClassAsSet(key, cl));

spring-orm/src/main/java/org/springframework/orm/jpa/SharedEntityManagerCreator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ public abstract class SharedEntityManagerCreator {
7171

7272
private static final Class<?>[] NO_ENTITY_MANAGER_INTERFACES = new Class<?>[0];
7373

74+
private static final Map<Class<?>, Class<?>[]> cachedQueryInterfaces = new ConcurrentReferenceHashMap<>(4);
75+
7476
private static final Set<String> transactionRequiringMethods = new HashSet<>(8);
7577

7678
private static final Set<String> queryTerminatingMethods = new HashSet<>(8);
7779

78-
private static final Map<Class<?>, Class[]> CACHED_QUERY_INTERFACES = new ConcurrentReferenceHashMap<>();
79-
8080
static {
8181
transactionRequiringMethods.add("joinTransaction");
8282
transactionRequiringMethods.add("flush");
@@ -314,7 +314,7 @@ else if (transactionRequiringMethods.contains(method.getName())) {
314314
if (result instanceof Query) {
315315
Query query = (Query) result;
316316
if (isNewEm) {
317-
Class<?>[] ifcs = CACHED_QUERY_INTERFACES.computeIfAbsent(query.getClass(), key ->
317+
Class<?>[] ifcs = cachedQueryInterfaces.computeIfAbsent(query.getClass(), key ->
318318
ClassUtils.getAllInterfacesForClass(key, this.proxyClassLoader));
319319
result = Proxy.newProxyInstance(this.proxyClassLoader, ifcs,
320320
new DeferredQueryInvocationHandler(query, target));

0 commit comments

Comments
 (0)