CustomCollections is now less invasive to ConversionService.

Removed the removal of the general collection-to-object converter as apparently some downstream Spring Data modules rely on it. This theoretically allows conversions of collections into maps but we now simply don't assume that not to work anymore.

Issue #2619.
This commit is contained in:
Oliver Drotbohm
2022-05-03 22:47:31 +02:00
parent 048a3ddb1b
commit 7f19125a7b
2 changed files with 1 additions and 7 deletions

View File

@@ -184,9 +184,6 @@ public class CustomCollections {
Assert.notNull(registry, "ConverterRegistry must not be null!");
// Remove general collection to anything conversion as that would also convert collections to maps
registry.removeConvertible(Collection.class, Object.class);
REGISTRARS.forEach(it -> it.registerConvertersIn(registry));
}
@@ -352,6 +349,7 @@ public class CustomCollections {
* @see org.springframework.data.util.CustomCollectionRegistrar#toJavaNativeCollection()
*/
@Override
@SuppressWarnings("null")
public Function<Object, Object> toJavaNativeCollection() {
return source -> source instanceof io.vavr.collection.Traversable

View File

@@ -95,7 +95,6 @@ class CustomCollectionsUnitTests {
assertThat(conversionService.canConvert(List.class, io.vavr.collection.Traversable.class)).isTrue();
assertThat(conversionService.canConvert(List.class, io.vavr.collection.List.class)).isTrue();
assertThat(conversionService.canConvert(List.class, io.vavr.collection.Set.class)).isTrue();
assertThat(conversionService.canConvert(List.class, io.vavr.collection.Map.class)).isFalse();
List<Integer> integers = Arrays.asList(1, 2, 3);
@@ -111,7 +110,6 @@ class CustomCollectionsUnitTests {
assertThat(conversionService.canConvert(Set.class, io.vavr.collection.Traversable.class)).isTrue();
assertThat(conversionService.canConvert(Set.class, io.vavr.collection.Set.class)).isTrue();
assertThat(conversionService.canConvert(Set.class, io.vavr.collection.List.class)).isTrue();
assertThat(conversionService.canConvert(Set.class, io.vavr.collection.Map.class)).isFalse();
Set<Integer> integers = Collections.singleton(1);
@@ -143,7 +141,6 @@ class CustomCollectionsUnitTests {
assertThat(conversionService.canConvert(List.class, ImmutableList.class)).isTrue();
assertThat(conversionService.canConvert(List.class, ImmutableSet.class)).isTrue();
assertThat(conversionService.canConvert(List.class, ImmutableBag.class)).isTrue();
assertThat(conversionService.canConvert(List.class, ImmutableMap.class)).isFalse();
List<Integer> integers = Arrays.asList(1, 2, 3);
@@ -162,7 +159,6 @@ class CustomCollectionsUnitTests {
assertThat(conversionService.canConvert(Set.class, ImmutableSet.class)).isTrue();
assertThat(conversionService.canConvert(Set.class, ImmutableBag.class)).isTrue();
assertThat(conversionService.canConvert(Set.class, ImmutableList.class)).isTrue();
assertThat(conversionService.canConvert(Set.class, ImmutableMap.class)).isFalse();
Set<Integer> integers = Collections.singleton(1);