2121import java .io .Serializable ;
2222import java .lang .annotation .Annotation ;
2323import java .util .*;
24+ import java .util .concurrent .ConcurrentHashMap ;
2425import java .util .stream .Collectors ;
2526
2627import org .springframework .core .annotation .AnnotatedElementUtils ;
3839import org .springframework .util .Assert ;
3940import org .springframework .util .CollectionUtils ;
4041import org .springframework .util .ConcurrentReferenceHashMap ;
42+ import org .springframework .util .ConcurrentReferenceHashMap .ReferenceType ;
4143import org .springframework .util .MultiValueMap ;
4244import org .springframework .util .StringUtils ;
4345
@@ -105,8 +107,9 @@ public BasicPersistentEntity(TypeInformation<T> information, @Nullable Comparato
105107 this .associations = comparator == null ? new HashSet <>() : new TreeSet <>(new AssociationComparator <>(comparator ));
106108
107109 this .propertyCache = new ConcurrentHashMap <>();
108- this .annotationCache = new ConcurrentReferenceHashMap <>();
109- this .propertyAnnotationCache = CollectionUtils .toMultiValueMap (new ConcurrentReferenceHashMap <>());
110+ this .annotationCache = new ConcurrentReferenceHashMap <>(16 , ReferenceType .WEAK );
111+ this .propertyAnnotationCache = CollectionUtils
112+ .toMultiValueMap (new ConcurrentReferenceHashMap <>(16 , ReferenceType .WEAK ));
110113 this .propertyAccessorFactory = BeanWrapperPropertyAccessorFactory .INSTANCE ;
111114 this .typeAlias = Lazy .of (() -> getAliasFromAnnotation (getType ()));
112115 this .isNewStrategy = Lazy .of (() -> Persistable .class .isAssignableFrom (information .getType ()) //
@@ -236,7 +239,7 @@ public void addPersistentProperty(P property) {
236239 }
237240 }
238241
239- /*
242+ /*
240243 * (non-Javadoc)
241244 * @see org.springframework.data.mapping.model.MutablePersistentEntity#setEvaluationContextProvider(org.springframework.data.spel.EvaluationContextProvider)
242245 */
@@ -469,7 +472,7 @@ public IdentifierAccessor getIdentifierAccessor(Object bean) {
469472 return hasIdProperty () ? new IdPropertyIdentifierAccessor (this , bean ) : new AbsentIdentifierAccessor (bean );
470473 }
471474
472- /*
475+ /*
473476 * (non-Javadoc)
474477 * @see org.springframework.data.mapping.PersistentEntity#isNew(java.lang.Object)
475478 */
@@ -481,7 +484,7 @@ public boolean isNew(Object bean) {
481484 return isNewStrategy .get ().isNew (bean );
482485 }
483486
484- /*
487+ /*
485488 * (non-Javadoc)
486489 * @see org.springframework.data.mapping.PersistentEntity#isImmutable()
487490 */
@@ -516,7 +519,7 @@ protected EvaluationContext getEvaluationContext(Object rootObject) {
516519 * Returns the default {@link IsNewStrategy} to be used. Will be a {@link PersistentEntityIsNewStrategy} by default.
517520 * Note, that this strategy only gets used if the entity doesn't implement {@link Persistable} as this indicates the
518521 * user wants to be in control over whether an entity is new or not.
519- *
522+ *
520523 * @return
521524 * @since 2.1
522525 */
@@ -526,7 +529,7 @@ protected IsNewStrategy getFallbackIsNewStrategy() {
526529
527530 /**
528531 * Verifies the given bean type to no be {@literal null} and of the type of the current {@link PersistentEntity}.
529- *
532+ *
530533 * @param bean must not be {@literal null}.
531534 */
532535 private final void verifyBeanType (Object bean ) {
0 commit comments