File tree Expand file tree Collapse file tree 5 files changed +27
-23
lines changed
main/java/org/springframework/data/repository
test/java/org/springframework/data/repository/util Expand file tree Collapse file tree 5 files changed +27
-23
lines changed Original file line number Diff line number Diff line change 27
27
import org .springframework .data .repository .core .CrudMethods ;
28
28
import org .springframework .data .repository .core .RepositoryMetadata ;
29
29
import org .springframework .data .repository .util .QueryExecutionConverters ;
30
+ import org .springframework .data .repository .util .ReactiveWrapperConverters ;
30
31
import org .springframework .data .repository .util .ReactiveWrappers ;
31
32
import org .springframework .data .util .ClassTypeInformation ;
32
33
import org .springframework .data .util .KotlinReflectionUtils ;
@@ -105,7 +106,14 @@ public TypeInformation<?> getReturnType(Method method) {
105
106
* @see org.springframework.data.repository.core.RepositoryMetadata#getReturnedDomainClass(java.lang.reflect.Method)
106
107
*/
107
108
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 ();
109
117
}
110
118
111
119
/*
Original file line number Diff line number Diff line change 38
38
import org .springframework .data .repository .core .support .MethodLookup .MethodPredicate ;
39
39
import org .springframework .data .repository .util .QueryExecutionConverters ;
40
40
import org .springframework .data .repository .util .ReactiveWrapperConverters ;
41
+ import org .springframework .data .repository .util .ReactiveWrappers ;
41
42
import org .springframework .util .Assert ;
42
43
import org .springframework .util .ObjectUtils ;
43
44
@@ -300,8 +301,7 @@ private static boolean isNonUnwrappingWrapper(Class<?> parameterType) {
300
301
301
302
Assert .notNull (parameterType , "Parameter type must not be null!" );
302
303
303
- return QueryExecutionConverters .supports (parameterType )
304
- && !QueryExecutionConverters .supportsUnwrapping (parameterType );
304
+ return ReactiveWrappers .supports (parameterType );
305
305
}
306
306
307
307
/**
Original file line number Diff line number Diff line change @@ -168,10 +168,6 @@ public static boolean supports(Class<?> type) {
168
168
}
169
169
}
170
170
171
- if (ReactiveWrappers .supports (type )) {
172
- return true ;
173
- }
174
-
175
171
return false ;
176
172
});
177
173
}
Original file line number Diff line number Diff line change 43
43
import org .springframework .core .convert .support .ConfigurableConversionService ;
44
44
import org .springframework .core .convert .support .GenericConversionService ;
45
45
import org .springframework .data .repository .util .ReactiveWrappers .ReactiveLibrary ;
46
+ import org .springframework .data .util .TypeInformation ;
46
47
import org .springframework .lang .Nullable ;
47
48
import org .springframework .util .Assert ;
48
49
import org .springframework .util .ClassUtils ;
@@ -149,6 +150,21 @@ public static boolean supports(Class<?> type) {
149
150
&& RegistryHolder .REACTIVE_ADAPTER_REGISTRY .getAdapter (type ) != null ;
150
151
}
151
152
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
+
152
168
/**
153
169
* Casts or adopts the given wrapper type to a target wrapper type.
154
170
*
Original file line number Diff line number Diff line change @@ -82,22 +82,6 @@ void registersWrapperTypes() {
82
82
assertThat (QueryExecutionConverters .supports (io .vavr .control .Option .class )).isTrue ();
83
83
}
84
84
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
-
101
85
@ Test // DATACMNS-836
102
86
void registersUnwrapperTypes () {
103
87
You can’t perform that action at this time.
0 commit comments