DATACMNS-1191 - Avoid unnecessary investigation of converters in QueryExecutionResultHandler.

On query execution conversion, we now check an unwrapped Optional's value for assignability to the target type before looking into advanced conversion options to avoid unnecessary code invocations that would eventually return the same instance anyway.
This commit is contained in:
Oliver Gierke
2017-10-06 12:14:48 +02:00
parent 5ebcee90c9
commit c9e0803bee

View File

@@ -66,12 +66,20 @@ class QueryExecutionResultHandler {
Class<?> expectedReturnType = returnTypeDescriptor.getType();
// Early return if the raw value matches
if (result != null && expectedReturnType.isInstance(result)) {
return result;
}
result = unwrapOptional(result);
// Early return if the unrwapped value matches
if (result != null && expectedReturnType.isInstance(result)) {
return result;
}
if (QueryExecutionConverters.supports(expectedReturnType)) {
TypeDescriptor targetType = TypeDescriptor.valueOf(expectedReturnType);