DATACMNS-1112 - Cache instances of ReturnedType to avoid repeated reflection inspection.

We now keep instances of ReturnedType around to avoid the repeated reflection inspection for constructor and parameter name detection for class types and projection information for interfaces.
This commit is contained in:
Oliver Gierke
2017-07-12 17:09:39 +02:00
parent 4d2cc9ab8e
commit d4b79ea8f2
2 changed files with 28 additions and 3 deletions

View File

@@ -157,6 +157,17 @@ public class ReturnedTypeUnitTests {
assertThat(properties).containsExactly("firstname");
}
@Test // DATACMNS-1112
public void cachesInstancesBySourceTypes() {
SpelAwareProxyProjectionFactory factory = new SpelAwareProxyProjectionFactory();
ReturnedType left = ReturnedType.of(Child.class, Object.class, factory);
ReturnedType right = ReturnedType.of(Child.class, Object.class, factory);
assertThat(left).isSameAs(right);
}
private static ReturnedType getReturnedType(String methodName, Class<?>... parameters) throws Exception {
return getQueryMethod(methodName, parameters).getResultProcessor().getReturnedType();
}