DATACMNS-1294 - Consider java.time types simple ones.
We now consider all types in the java.time package as simple types to prevent deep reflective access. We are already excluding java.lang types for the same reason. Original pull request: #286.
This commit is contained in:
committed by
Oliver Gierke
parent
d85e9e117e
commit
2d24acf9de
@@ -155,7 +155,9 @@ public class SimpleTypeHolder {
|
||||
return isSimpleType;
|
||||
}
|
||||
|
||||
if (type.getName().startsWith("java.lang")) {
|
||||
String typeName = type.getName();
|
||||
|
||||
if (typeName.startsWith("java.lang") || type.getName().startsWith("java.time")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -170,6 +172,7 @@ public class SimpleTypeHolder {
|
||||
}
|
||||
|
||||
this.simpleTypes = put(localSimpleTypes, type, false);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.data.mapping;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.time.Instant;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
@@ -114,6 +115,14 @@ public class SimpleTypeHolderUnitTests {
|
||||
assertThat(holder.isSimpleType(Type.class)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1294
|
||||
public void considersJavaTimeTypesSimple() {
|
||||
|
||||
SimpleTypeHolder holder = SimpleTypeHolder.DEFAULT;
|
||||
|
||||
assertThat(holder.isSimpleType(Instant.class)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1101
|
||||
public void considersExtendedTypeAsSimple() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user