Skip to content

Commit 24c1b82

Browse files
committed
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.
1 parent 309cdc5 commit 24c1b82

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

src/main/java/org/springframework/data/mapping/model/BasicPersistentEntity.java

+14-4
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,23 @@
3030
import java.util.Optional;
3131
import java.util.Set;
3232
import java.util.TreeSet;
33-
import java.util.concurrent.ConcurrentHashMap;
3433
import java.util.stream.Collectors;
3534

3635
import org.springframework.core.annotation.AnnotatedElementUtils;
3736
import org.springframework.data.annotation.TypeAlias;
38-
import org.springframework.data.mapping.*;
37+
import org.springframework.data.mapping.Alias;
38+
import org.springframework.data.mapping.Association;
39+
import org.springframework.data.mapping.AssociationHandler;
40+
import org.springframework.data.mapping.IdentifierAccessor;
41+
import org.springframework.data.mapping.MappingException;
42+
import org.springframework.data.mapping.PersistentEntity;
43+
import org.springframework.data.mapping.PersistentProperty;
44+
import org.springframework.data.mapping.PersistentPropertyAccessor;
45+
import org.springframework.data.mapping.PreferredConstructor;
46+
import org.springframework.data.mapping.PropertyHandler;
47+
import org.springframework.data.mapping.SimpleAssociationHandler;
48+
import org.springframework.data.mapping.SimplePropertyHandler;
49+
import org.springframework.data.mapping.TargetAwareIdentifierAccessor;
3950
import org.springframework.data.util.Lazy;
4051
import org.springframework.data.util.TypeInformation;
4152
import org.springframework.lang.Nullable;
@@ -106,8 +117,7 @@ public BasicPersistentEntity(TypeInformation<T> information, @Nullable Comparato
106117

107118
this.propertyCache = new ConcurrentReferenceHashMap<>();
108119
this.annotationCache = new ConcurrentReferenceHashMap<>();
109-
this.propertyAnnotationCache = CollectionUtils
110-
.toMultiValueMap(new ConcurrentReferenceHashMap<Class<? extends Annotation>, List<P>>());
120+
this.propertyAnnotationCache = CollectionUtils.toMultiValueMap(new ConcurrentReferenceHashMap<>());
111121
this.propertyAccessorFactory = BeanWrapperPropertyAccessorFactory.INSTANCE;
112122
this.typeAlias = Lazy.of(() -> getAliasFromAnnotation(getType()));
113123
}

src/test/java/org/springframework/data/mapping/model/BasicPersistentEntityUnitTests.java

+5-8
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
import org.springframework.data.mapping.context.SampleMappingContext;
5656
import org.springframework.data.mapping.context.SamplePersistentProperty;
5757
import org.springframework.data.util.ClassTypeInformation;
58-
import org.springframework.data.util.Version;
58+
import org.springframework.lang.Nullable;
5959
import org.springframework.test.util.ReflectionTestUtils;
6060

6161
/**
@@ -286,19 +286,16 @@ public void getRequiredAnnotationThrowsException() {
286286
@Test // DATACMNS-1210
287287
public void findAnnotationShouldBeThreadSafe() throws InterruptedException {
288288

289-
assumeTrue("Requires Java 9",
290-
Version.parse(System.getProperty("java.version")).isGreaterThanOrEqualTo(Version.parse("9.0")));
291-
292289
CountDownLatch latch = new CountDownLatch(2);
293290
CountDownLatch syncLatch = new CountDownLatch(1);
291+
AtomicBoolean failed = new AtomicBoolean(false);
294292

295-
final AtomicBoolean failed = new AtomicBoolean(false);
296-
297-
PersistentEntity<EntityWithAnnotation, T> entity = new BasicPersistentEntity(
293+
PersistentEntity<EntityWithAnnotation, T> entity = new BasicPersistentEntity<EntityWithAnnotation, T>(
298294
ClassTypeInformation.from(EntityWithAnnotation.class), null) {
299295

296+
@Nullable
300297
@Override
301-
public Annotation findAnnotation(Class annotationType) {
298+
public <A extends Annotation> A findAnnotation(Class<A> annotationType) {
302299

303300
try {
304301
syncLatch.await();

0 commit comments

Comments
 (0)