Skip to content

Commit e50e013

Browse files
committed
DATACMNS-1364 - Polishing.
Use weak references in annotation and property annotation cache to retain references until the last GC root is cleared. Remove trailing whitespaces. Reformat. Original pull request: #304.
1 parent 7d32223 commit e50e013

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Diff for: src/main/java/org/springframework/data/mapping/model/BasicPersistentEntity.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import org.springframework.util.Assert;
3939
import org.springframework.util.CollectionUtils;
4040
import org.springframework.util.ConcurrentReferenceHashMap;
41+
import org.springframework.util.ConcurrentReferenceHashMap.ReferenceType;
4142
import org.springframework.util.MultiValueMap;
4243
import org.springframework.util.StringUtils;
4344

@@ -105,8 +106,9 @@ public BasicPersistentEntity(TypeInformation<T> information, @Nullable Comparato
105106
this.associations = comparator == null ? new HashSet<>() : new TreeSet<>(new AssociationComparator<>(comparator));
106107

107108
this.propertyCache = new HashMap<>();
108-
this.annotationCache = new ConcurrentReferenceHashMap<>();
109-
this.propertyAnnotationCache = CollectionUtils.toMultiValueMap(new ConcurrentReferenceHashMap<>());
109+
this.annotationCache = new ConcurrentReferenceHashMap<>(16, ReferenceType.WEAK);
110+
this.propertyAnnotationCache = CollectionUtils
111+
.toMultiValueMap(new ConcurrentReferenceHashMap<>(16, ReferenceType.WEAK));
110112
this.propertyAccessorFactory = BeanWrapperPropertyAccessorFactory.INSTANCE;
111113
this.typeAlias = Lazy.of(() -> getAliasFromAnnotation(getType()));
112114
this.isNewStrategy = Lazy.of(() -> Persistable.class.isAssignableFrom(information.getType()) //

0 commit comments

Comments
 (0)