DATACMNS-867 - ReflectionRepositoryInvoker now avoids ConversionService for Optional creation.

We now manually create Optional instances as the ConversionService converts single-argument collections into an optional with only that element.
This commit is contained in:
Oliver Gierke
2017-03-22 23:28:11 +01:00
parent fe5d543ff2
commit 429dcbf659
2 changed files with 18 additions and 10 deletions

View File

@@ -253,16 +253,8 @@ class ReflectionRepositoryInvoker implements RepositoryInvoker {
@SuppressWarnings("unchecked")
private <T> Optional<T> returnAsOptional(Object source) {
if (Optional.class.isInstance(source)) {
return (Optional<T>) source;
}
if (source == null) {
return Optional.empty();
}
return conversionService.convert(QueryExecutionConverters.unwrap(source), Optional.class);
return (Optional<T>) (Optional.class.isInstance(source) ? source
: Optional.ofNullable(QueryExecutionConverters.unwrap(source)));
}
/**