Skip to content

Commit 7f19125

Browse files
committed
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.
1 parent 048a3dd commit 7f19125

File tree

2 files changed

+1
-7
lines changed

2 files changed

+1
-7
lines changed

src/main/java/org/springframework/data/util/CustomCollections.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,6 @@ public static void registerConvertersIn(ConverterRegistry registry) {
184184

185185
Assert.notNull(registry, "ConverterRegistry must not be null!");
186186

187-
// Remove general collection to anything conversion as that would also convert collections to maps
188-
registry.removeConvertible(Collection.class, Object.class);
189-
190187
REGISTRARS.forEach(it -> it.registerConvertersIn(registry));
191188
}
192189

@@ -352,6 +349,7 @@ public void registerConvertersIn(ConverterRegistry registry) {
352349
* @see org.springframework.data.util.CustomCollectionRegistrar#toJavaNativeCollection()
353350
*/
354351
@Override
352+
@SuppressWarnings("null")
355353
public Function<Object, Object> toJavaNativeCollection() {
356354

357355
return source -> source instanceof io.vavr.collection.Traversable

src/test/java/org/springframework/data/util/CustomCollectionsUnitTests.java

-4
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ void conversListToVavr() {
9595
assertThat(conversionService.canConvert(List.class, io.vavr.collection.Traversable.class)).isTrue();
9696
assertThat(conversionService.canConvert(List.class, io.vavr.collection.List.class)).isTrue();
9797
assertThat(conversionService.canConvert(List.class, io.vavr.collection.Set.class)).isTrue();
98-
assertThat(conversionService.canConvert(List.class, io.vavr.collection.Map.class)).isFalse();
9998

10099
List<Integer> integers = Arrays.asList(1, 2, 3);
101100

@@ -111,7 +110,6 @@ void convertsSetToVavr() {
111110
assertThat(conversionService.canConvert(Set.class, io.vavr.collection.Traversable.class)).isTrue();
112111
assertThat(conversionService.canConvert(Set.class, io.vavr.collection.Set.class)).isTrue();
113112
assertThat(conversionService.canConvert(Set.class, io.vavr.collection.List.class)).isTrue();
114-
assertThat(conversionService.canConvert(Set.class, io.vavr.collection.Map.class)).isFalse();
115113

116114
Set<Integer> integers = Collections.singleton(1);
117115

@@ -143,7 +141,6 @@ void conversListToEclipse() {
143141
assertThat(conversionService.canConvert(List.class, ImmutableList.class)).isTrue();
144142
assertThat(conversionService.canConvert(List.class, ImmutableSet.class)).isTrue();
145143
assertThat(conversionService.canConvert(List.class, ImmutableBag.class)).isTrue();
146-
assertThat(conversionService.canConvert(List.class, ImmutableMap.class)).isFalse();
147144

148145
List<Integer> integers = Arrays.asList(1, 2, 3);
149146

@@ -162,7 +159,6 @@ void convertsSetToEclipse() {
162159
assertThat(conversionService.canConvert(Set.class, ImmutableSet.class)).isTrue();
163160
assertThat(conversionService.canConvert(Set.class, ImmutableBag.class)).isTrue();
164161
assertThat(conversionService.canConvert(Set.class, ImmutableList.class)).isTrue();
165-
assertThat(conversionService.canConvert(Set.class, ImmutableMap.class)).isFalse();
166162

167163
Set<Integer> integers = Collections.singleton(1);
168164

0 commit comments

Comments
 (0)