Browse Source

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.
pull/271/head
Oliver Gierke 8 years ago
parent
commit
d3fb691220
  1. 8
      src/main/java/org/springframework/data/repository/core/support/QueryExecutionResultHandler.java

8
src/main/java/org/springframework/data/repository/core/support/QueryExecutionResultHandler.java

@ -66,12 +66,20 @@ class QueryExecutionResultHandler { @@ -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);

Loading…
Cancel
Save