DATACMNS-1294 - Consider java.time types simple ones.

To prevent repeated failing calls to ClassUtils.forName(…) we now also cache the failed attempt and simply eagerly return null as subsequent similar attempts to resolve a class are going to fail anyway.

Original pull request: #286.
This commit is contained in:
Oliver Gierke
2018-04-18 18:51:47 +02:00
parent 8d99e0d83d
commit 5708d6af12
2 changed files with 12 additions and 1 deletions

View File

@@ -123,7 +123,9 @@ public class SimpleTypeHolder {
return true;
}
if (type.getName().startsWith("java.lang")) {
String typeName = type.getName();
if (typeName.startsWith("java.lang") || typeName.startsWith("java.time")) {
return true;
}

View File

@@ -19,6 +19,7 @@ import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
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), is(true));
}
@Test // DATACMNS-1294
public void considersJavaTimeTypesSimple() {
SimpleTypeHolder holder = new SimpleTypeHolder();
assertThat(holder.isSimpleType(Instant.class), is(true));
}
enum SimpleEnum {
FOO;