DATACMNS-1484 - Fixed too aggressive conversion to Streamable in IterableToStreamableConverter.
We now explicitly check for the target type to be assignable to Streamable to opt into conversion. Without that check, every collection returned from a method declaring Iterable as return type would've been converted into a Streamable by accident. Related ticket: DATACMNS-1430.
This commit is contained in:
@@ -699,6 +699,10 @@ public abstract class QueryExecutionConverters {
|
||||
@Override
|
||||
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||
|
||||
if (sourceType.isAssignableTo(targetType)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Iterable.class.isAssignableFrom(sourceType.getType())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -355,6 +355,15 @@ public class QueryExecutionConvertersUnitTests {
|
||||
.containsExactly("foo");
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1484
|
||||
public void doesNotConvertCollectionToStreamableIfReturnTypeIsIterable() {
|
||||
|
||||
List<String> source = Arrays.asList("1", "2");
|
||||
|
||||
assertThat(conversionService.convert(source, Iterable.class)).isSameAs(source);
|
||||
|
||||
}
|
||||
|
||||
interface Sample {
|
||||
|
||||
Page<String> pages();
|
||||
|
||||
Reference in New Issue
Block a user