Skip to content

Commit 9ced611

Browse files
mp911dechristophstrobl
authored andcommitted
DATACMNS-1762 - Remove ReactiveWrappers support from from QueryExecutionConverters.
ReactiveWrappers doesn't belong in there in the first place so we're removing ReactiveWrappers support from QueryExecutionConverters so ReactiveWrappers is used from parts that need to be reactive-aware. Original Pull Request: #459
1 parent eadbe80 commit 9ced611

File tree

5 files changed

+27
-23
lines changed

5 files changed

+27
-23
lines changed

src/main/java/org/springframework/data/repository/core/support/AbstractRepositoryMetadata.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.springframework.data.repository.core.CrudMethods;
2828
import org.springframework.data.repository.core.RepositoryMetadata;
2929
import org.springframework.data.repository.util.QueryExecutionConverters;
30+
import org.springframework.data.repository.util.ReactiveWrapperConverters;
3031
import org.springframework.data.repository.util.ReactiveWrappers;
3132
import org.springframework.data.util.ClassTypeInformation;
3233
import org.springframework.data.util.KotlinReflectionUtils;
@@ -105,7 +106,14 @@ public TypeInformation<?> getReturnType(Method method) {
105106
* @see org.springframework.data.repository.core.RepositoryMetadata#getReturnedDomainClass(java.lang.reflect.Method)
106107
*/
107108
public Class<?> getReturnedDomainClass(Method method) {
108-
return QueryExecutionConverters.unwrapWrapperTypes(getReturnType(method)).getType();
109+
110+
TypeInformation<?> returnType = getReturnType(method);
111+
112+
if (ReactiveWrapperConverters.supports(returnType.getType())) {
113+
return ReactiveWrapperConverters.unwrapWrapperTypes(returnType).getType();
114+
}
115+
116+
return QueryExecutionConverters.unwrapWrapperTypes(returnType).getType();
109117
}
110118

111119
/*

src/main/java/org/springframework/data/repository/core/support/MethodLookups.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import org.springframework.data.repository.core.support.MethodLookup.MethodPredicate;
3939
import org.springframework.data.repository.util.QueryExecutionConverters;
4040
import org.springframework.data.repository.util.ReactiveWrapperConverters;
41+
import org.springframework.data.repository.util.ReactiveWrappers;
4142
import org.springframework.util.Assert;
4243
import org.springframework.util.ObjectUtils;
4344

@@ -300,8 +301,7 @@ private static boolean isNonUnwrappingWrapper(Class<?> parameterType) {
300301

301302
Assert.notNull(parameterType, "Parameter type must not be null!");
302303

303-
return QueryExecutionConverters.supports(parameterType)
304-
&& !QueryExecutionConverters.supportsUnwrapping(parameterType);
304+
return ReactiveWrappers.supports(parameterType);
305305
}
306306

307307
/**

src/main/java/org/springframework/data/repository/util/QueryExecutionConverters.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,6 @@ public static boolean supports(Class<?> type) {
168168
}
169169
}
170170

171-
if (ReactiveWrappers.supports(type)) {
172-
return true;
173-
}
174-
175171
return false;
176172
});
177173
}

src/main/java/org/springframework/data/repository/util/ReactiveWrapperConverters.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import org.springframework.core.convert.support.ConfigurableConversionService;
4444
import org.springframework.core.convert.support.GenericConversionService;
4545
import org.springframework.data.repository.util.ReactiveWrappers.ReactiveLibrary;
46+
import org.springframework.data.util.TypeInformation;
4647
import org.springframework.lang.Nullable;
4748
import org.springframework.util.Assert;
4849
import org.springframework.util.ClassUtils;
@@ -149,6 +150,21 @@ public static boolean supports(Class<?> type) {
149150
&& RegistryHolder.REACTIVE_ADAPTER_REGISTRY.getAdapter(type) != null;
150151
}
151152

153+
/**
154+
* Recursively unwraps well known wrapper types from the given {@link TypeInformation}.
155+
*
156+
* @param type must not be {@literal null}.
157+
* @return will never be {@literal null}.
158+
*/
159+
public static TypeInformation<?> unwrapWrapperTypes(TypeInformation<?> type) {
160+
161+
Assert.notNull(type, "type must not be null");
162+
163+
Class<?> rawType = type.getType();
164+
165+
return supports(rawType) ? unwrapWrapperTypes(type.getRequiredComponentType()) : type;
166+
}
167+
152168
/**
153169
* Casts or adopts the given wrapper type to a target wrapper type.
154170
*

src/test/java/org/springframework/data/repository/util/QueryExecutionConvertersUnitTests.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -82,22 +82,6 @@ void registersWrapperTypes() {
8282
assertThat(QueryExecutionConverters.supports(io.vavr.control.Option.class)).isTrue();
8383
}
8484

85-
@Test // DATACMNS-836
86-
void registersReactiveWrapperTypes() {
87-
88-
assertThat(QueryExecutionConverters.supports(Publisher.class)).isTrue();
89-
assertThat(QueryExecutionConverters.supports(Mono.class)).isTrue();
90-
assertThat(QueryExecutionConverters.supports(Flux.class)).isTrue();
91-
assertThat(QueryExecutionConverters.supports(Single.class)).isTrue();
92-
assertThat(QueryExecutionConverters.supports(Completable.class)).isTrue();
93-
assertThat(QueryExecutionConverters.supports(Observable.class)).isTrue();
94-
assertThat(QueryExecutionConverters.supports(io.reactivex.Single.class)).isTrue();
95-
assertThat(QueryExecutionConverters.supports(io.reactivex.Maybe.class)).isTrue();
96-
assertThat(QueryExecutionConverters.supports(io.reactivex.Completable.class)).isTrue();
97-
assertThat(QueryExecutionConverters.supports(io.reactivex.Flowable.class)).isTrue();
98-
assertThat(QueryExecutionConverters.supports(io.reactivex.Observable.class)).isTrue();
99-
}
100-
10185
@Test // DATACMNS-836
10286
void registersUnwrapperTypes() {
10387

0 commit comments

Comments
 (0)