Skip to content

Commit 23ad2f0

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 0305917 commit 23ad2f0

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,6 @@ public static void registerConvertersIn(ConverterRegistry registry) {
182182

183183
Assert.notNull(registry, "ConverterRegistry must not be null!");
184184

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

@@ -350,6 +347,7 @@ public void registerConvertersIn(ConverterRegistry registry) {
350347
* @see org.springframework.data.util.CustomCollectionRegistrar#toJavaNativeCollection()
351348
*/
352349
@Override
350+
@SuppressWarnings("null")
353351
public Function<Object, Object> toJavaNativeCollection() {
354352

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

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

Lines changed: 0 additions & 4 deletions
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
var integers = Arrays.asList(1, 2, 3);
101100

@@ -110,7 +109,6 @@ void convertsSetToVavr() {
110109
assertThat(conversionService.canConvert(Set.class, io.vavr.collection.Traversable.class)).isTrue();
111110
assertThat(conversionService.canConvert(Set.class, io.vavr.collection.Set.class)).isTrue();
112111
assertThat(conversionService.canConvert(Set.class, io.vavr.collection.List.class)).isTrue();
113-
assertThat(conversionService.canConvert(Set.class, io.vavr.collection.Map.class)).isFalse();
114112

115113
var integers = Collections.singleton(1);
116114

@@ -141,7 +139,6 @@ void conversListToEclipse() {
141139
assertThat(conversionService.canConvert(List.class, ImmutableList.class)).isTrue();
142140
assertThat(conversionService.canConvert(List.class, ImmutableSet.class)).isTrue();
143141
assertThat(conversionService.canConvert(List.class, ImmutableBag.class)).isTrue();
144-
assertThat(conversionService.canConvert(List.class, ImmutableMap.class)).isFalse();
145142

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

@@ -160,7 +157,6 @@ void convertsSetToEclipse() {
160157
assertThat(conversionService.canConvert(Set.class, ImmutableSet.class)).isTrue();
161158
assertThat(conversionService.canConvert(Set.class, ImmutableBag.class)).isTrue();
162159
assertThat(conversionService.canConvert(Set.class, ImmutableList.class)).isTrue();
163-
assertThat(conversionService.canConvert(Set.class, ImmutableMap.class)).isFalse();
164160

165161
var integers = Collections.singleton(1);
166162

0 commit comments

Comments
 (0)