Skip to content

Commit b18e340

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 a85b4f3 commit b18e340

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
@@ -33,6 +33,7 @@
3333
import org.springframework.util.Assert;
3434
import org.springframework.util.CollectionUtils;
3535
import org.springframework.util.ConcurrentReferenceHashMap;
36+
import org.springframework.util.ConcurrentReferenceHashMap.ReferenceType;
3637
import org.springframework.util.MultiValueMap;
3738
import org.springframework.util.StringUtils;
3839

@@ -96,8 +97,9 @@ public BasicPersistentEntity(TypeInformation<T> information, @Nullable Comparato
9697
this.associations = comparator == null ? new HashSet<>() : new TreeSet<>(new AssociationComparator<>(comparator));
9798

9899
this.propertyCache = new HashMap<>();
99-
this.annotationCache = new ConcurrentReferenceHashMap<>();
100-
this.propertyAnnotationCache = CollectionUtils.toMultiValueMap(new ConcurrentReferenceHashMap<>());
100+
this.annotationCache = new ConcurrentReferenceHashMap<>(16, ReferenceType.WEAK);
101+
this.propertyAnnotationCache = CollectionUtils
102+
.toMultiValueMap(new ConcurrentReferenceHashMap<>(16, ReferenceType.WEAK));
101103
this.propertyAccessorFactory = BeanWrapperPropertyAccessorFactory.INSTANCE;
102104
this.typeAlias = Lazy.of(() -> getAliasFromAnnotation(getType()));
103105
}

0 commit comments

Comments
 (0)