DATACMNS-1210 - Polishing.
More fixes of imports. Removed obsolete generics in constructor expressions. Removed a couple of compiler warnings in test cases. Removed assumption for test case to only run on JDK 9. Original pull request: #259.
This commit is contained in:
@@ -30,12 +30,23 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.core.annotation.AnnotatedElementUtils;
|
||||
import org.springframework.data.annotation.TypeAlias;
|
||||
import org.springframework.data.mapping.*;
|
||||
import org.springframework.data.mapping.Alias;
|
||||
import org.springframework.data.mapping.Association;
|
||||
import org.springframework.data.mapping.AssociationHandler;
|
||||
import org.springframework.data.mapping.IdentifierAccessor;
|
||||
import org.springframework.data.mapping.MappingException;
|
||||
import org.springframework.data.mapping.PersistentEntity;
|
||||
import org.springframework.data.mapping.PersistentProperty;
|
||||
import org.springframework.data.mapping.PersistentPropertyAccessor;
|
||||
import org.springframework.data.mapping.PreferredConstructor;
|
||||
import org.springframework.data.mapping.PropertyHandler;
|
||||
import org.springframework.data.mapping.SimpleAssociationHandler;
|
||||
import org.springframework.data.mapping.SimplePropertyHandler;
|
||||
import org.springframework.data.mapping.TargetAwareIdentifierAccessor;
|
||||
import org.springframework.data.util.Lazy;
|
||||
import org.springframework.data.util.TypeInformation;
|
||||
import org.springframework.lang.Nullable;
|
||||
@@ -106,8 +117,7 @@ public class BasicPersistentEntity<T, P extends PersistentProperty<P>> implement
|
||||
|
||||
this.propertyCache = new ConcurrentReferenceHashMap<>();
|
||||
this.annotationCache = new ConcurrentReferenceHashMap<>();
|
||||
this.propertyAnnotationCache = CollectionUtils
|
||||
.toMultiValueMap(new ConcurrentReferenceHashMap<Class<? extends Annotation>, List<P>>());
|
||||
this.propertyAnnotationCache = CollectionUtils.toMultiValueMap(new ConcurrentReferenceHashMap<>());
|
||||
this.propertyAccessorFactory = BeanWrapperPropertyAccessorFactory.INSTANCE;
|
||||
this.typeAlias = Lazy.of(() -> getAliasFromAnnotation(getType()));
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ import org.springframework.data.mapping.Person;
|
||||
import org.springframework.data.mapping.context.SampleMappingContext;
|
||||
import org.springframework.data.mapping.context.SamplePersistentProperty;
|
||||
import org.springframework.data.util.ClassTypeInformation;
|
||||
import org.springframework.data.util.Version;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
/**
|
||||
@@ -286,19 +286,16 @@ public class BasicPersistentEntityUnitTests<T extends PersistentProperty<T>> {
|
||||
@Test // DATACMNS-1210
|
||||
public void findAnnotationShouldBeThreadSafe() throws InterruptedException {
|
||||
|
||||
assumeTrue("Requires Java 9",
|
||||
Version.parse(System.getProperty("java.version")).isGreaterThanOrEqualTo(Version.parse("9.0")));
|
||||
|
||||
CountDownLatch latch = new CountDownLatch(2);
|
||||
CountDownLatch syncLatch = new CountDownLatch(1);
|
||||
AtomicBoolean failed = new AtomicBoolean(false);
|
||||
|
||||
final AtomicBoolean failed = new AtomicBoolean(false);
|
||||
|
||||
PersistentEntity<EntityWithAnnotation, T> entity = new BasicPersistentEntity(
|
||||
PersistentEntity<EntityWithAnnotation, T> entity = new BasicPersistentEntity<EntityWithAnnotation, T>(
|
||||
ClassTypeInformation.from(EntityWithAnnotation.class), null) {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Annotation findAnnotation(Class annotationType) {
|
||||
public <A extends Annotation> A findAnnotation(Class<A> annotationType) {
|
||||
|
||||
try {
|
||||
syncLatch.await();
|
||||
|
||||
Reference in New Issue
Block a user